summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-05 12:38:28 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-05 12:38:28 -0800
commit531889f410e72460fb5fcd5c061f31cead2026d2 (patch)
tree7363ebdee7b0895b0eeaae4474bf80e730e0b84f /core
parentb949732745486c68b7638b03cd726bb9ac8d3914 (diff)
downloadmill-531889f410e72460fb5fcd5c061f31cead2026d2.tar.gz
mill-531889f410e72460fb5fcd5c061f31cead2026d2.tar.bz2
mill-531889f410e72460fb5fcd5c061f31cead2026d2.zip
Add multiple-identical-apply-calls unit test
Diffstat (limited to 'core')
-rw-r--r--core/src/test/scala/forge/ApplicativeTests.scala10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/src/test/scala/forge/ApplicativeTests.scala b/core/src/test/scala/forge/ApplicativeTests.scala
index 621dc679..aff635f5 100644
--- a/core/src/test/scala/forge/ApplicativeTests.scala
+++ b/core/src/test/scala/forge/ApplicativeTests.scala
@@ -106,6 +106,16 @@ object ApplicativeTests extends TestSuite {
down2 == Some(Seq("hello2", "hello2hello2", "hello2hello2hello2"))
)
}
+ 'appliesEvaluatedOncePerLexicalCallsite - {
+ // If you have multiple Applyable#apply() lexically in the source code of
+ // your Opt{...} call, each one gets evaluated once, even if the LHS of each
+ // apply() call is identical. It's up to the downstream zipMap()
+ // implementation to decide if it wants to dedup them or do other things.
+ val counter = new Counter()
+ def up = Opt{ "hello" + counter() }
+ val down = Opt{ Seq(1, 2, 3).map(n => n + up() + up()) }
+ assert(down == Some(Seq("1hello1hello2", "2hello1hello2", "3hello1hello2")))
+ }
}
}