diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-22 22:06:27 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-22 22:06:27 -0700 |
commit | 822be02a29d7073c7f2fe9b74df7cc42e56d762c (patch) | |
tree | 1812e53e1dc8626e13f70300aa34121c23b9e92d /src/test/scala/forge/ForgeTests.scala | |
parent | d57ad0b63b54076d9182fdb75df9e38c8b30b58c (diff) | |
download | mill-822be02a29d7073c7f2fe9b74df7cc42e56d762c.tar.gz mill-822be02a29d7073c7f2fe9b74df7cc42e56d762c.tar.bz2 mill-822be02a29d7073c7f2fe9b74df7cc42e56d762c.zip |
Swap over to new macro-based `DefCtx` injection, rather than relying on `StaticContext`
This should let us avoid the same `StaticContext` being re-used by multiple implicit use-sites within a block, causing confusion.
`ForgeTests.evaluate.anonTriple` still doesn't pass for unrelated reasons
Diffstat (limited to 'src/test/scala/forge/ForgeTests.scala')
-rw-r--r-- | src/test/scala/forge/ForgeTests.scala | 117 |
1 files changed, 59 insertions, 58 deletions
diff --git a/src/test/scala/forge/ForgeTests.scala b/src/test/scala/forge/ForgeTests.scala index 07e753c6..ae6cfcf4 100644 --- a/src/test/scala/forge/ForgeTests.scala +++ b/src/test/scala/forge/ForgeTests.scala @@ -6,28 +6,28 @@ import java.nio.{file => jnio} object ForgeTests extends TestSuite{ val tests = Tests{ - implicit def fakeStaticContext = DefCtx.StaticContext(true) val evaluator = new Evaluator(jnio.Paths.get("target/workspace"), implicitly) object Singleton { - val single = test() + val single = T{ test() } } object Pair { - val up = test() - val down = test(up) + val up = T{ test() } + val down = T{ test(up) } } + object AnonTriple{ - val up = test() - val down = test(test(up)) + val up = T{ test() } + val down = T{ test(test(up)) } } object Diamond{ - val up = test() - val left = test(up) - val right = test(up) - val down = test(left, right) + val up = T{ test() } + val left = T{ test(up) } + val right = T{ test(up) } + val down = T{ test(left, right) } } object AnonDiamond{ - val up = test() - val down = test(test(up), test(up)) + val up = T{ test() } + val down = T{ test(test(up), test(up)) } } 'topoSortedTransitiveTargets - { @@ -35,6 +35,7 @@ object ForgeTests extends TestSuite{ val result = Evaluator.topoSortedTransitiveTargets(targets) assert(result == expected) } + 'singleton - check( targets = Seq(Singleton.single), expected = Seq(Singleton.single) @@ -60,60 +61,60 @@ object ForgeTests extends TestSuite{ Diamond.down ) ) + } + 'evaluate - { + def check(targets: Seq[Target[_]], + values: Seq[Any], + evaluated: Seq[Target[_]]) = { + val Evaluator.Results(returnedValues, returnedEvaluated) = evaluator.evaluate(targets) + assert( + returnedValues == values, + returnedEvaluated == evaluated + ) - 'evaluate - { - def check(targets: Seq[Target[_]], - values: Seq[Any], - evaluated: Seq[Target[_]]) = { - val Evaluator.Results(returnedValues, returnedEvaluated) = evaluator.evaluate(targets) - assert( - returnedValues == values, - returnedEvaluated == evaluated - ) - - } - 'singleton - { - import Singleton._ - // First time the target is evaluated - check(Seq(single), values = Seq(0), evaluated = Seq(single)) - // Second time the value is already cached, so no evaluation needed - check(Seq(single), values = Seq(0), evaluated = Seq()) - single.counter += 1 - // After incrementing the counter, it forces re-evaluation - check(Seq(single), values = Seq(1), evaluated = Seq(single)) - // Then it's cached again - check(Seq(single), values = Seq(1), evaluated = Seq()) - } - 'pair - { - import Pair._ - check(Seq(down), values = Seq(0), evaluated = Seq(up, down)) - check(Seq(down), values = Seq(0), evaluated = Seq()) + } + 'singleton - { + import Singleton._ + // First time the target is evaluated + check(Seq(single), values = Seq(0), evaluated = Seq(single)) + // Second time the value is already cached, so no evaluation needed + check(Seq(single), values = Seq(0), evaluated = Seq()) + single.counter += 1 + // After incrementing the counter, it forces re-evaluation + check(Seq(single), values = Seq(1), evaluated = Seq(single)) + // Then it's cached again + check(Seq(single), values = Seq(1), evaluated = Seq()) + } + 'pair - { + import Pair._ + check(Seq(down), values = Seq(0), evaluated = Seq(up, down)) + check(Seq(down), values = Seq(0), evaluated = Seq()) - down.counter += 1 - check(Seq(down), values = Seq(1), evaluated = Seq(down)) - check(Seq(down), values = Seq(1), evaluated = Seq()) + down.counter += 1 + check(Seq(down), values = Seq(1), evaluated = Seq(down)) + check(Seq(down), values = Seq(1), evaluated = Seq()) - up.counter += 1 - check(Seq(down), values = Seq(2), evaluated = Seq(up, down)) - check(Seq(down), values = Seq(2), evaluated = Seq()) - } - 'anonTriple - { - import AnonTriple._ - val middle = down.inputs(0) - check(Seq(down), values = Seq(0), evaluated = Seq(up, middle, down)) - check(Seq(down), values = Seq(0), evaluated = Seq()) + up.counter += 1 + check(Seq(down), values = Seq(2), evaluated = Seq(up, down)) + check(Seq(down), values = Seq(2), evaluated = Seq()) + } + 'anonTriple - { + import AnonTriple._ + val middle = down.inputs(0) + check(Seq(down), values = Seq(0), evaluated = Seq(up, middle, down)) + check(Seq(down), values = Seq(0), evaluated = Seq()) - down.counter += 1 - check(Seq(down), values = Seq(1), evaluated = Seq(middle, down)) - check(Seq(down), values = Seq(1), evaluated = Seq()) + down.counter += 1 + check(Seq(down), values = Seq(1), evaluated = Seq(middle, down)) + check(Seq(down), values = Seq(1), evaluated = Seq()) - up.counter += 1 - check(Seq(down), values = Seq(2), evaluated = Seq(up, middle, down)) - check(Seq(down), values = Seq(2), evaluated = Seq()) - } + up.counter += 1 + check(Seq(down), values = Seq(2), evaluated = Seq(up, middle, down)) + check(Seq(down), values = Seq(2), evaluated = Seq()) } } + // 'full - { // val sourceRoot = Target.path(jnio.Paths.get("src/test/resources/example/src")) // val resourceRoot = Target.path(jnio.Paths.get("src/test/resources/example/resources")) |