From 6f2de230b39fb9f178df7c2470b667f7f4377478 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 21 Oct 2017 20:09:20 -0700 Subject: Add `StaticContext` macro to let us distinguish top-level targets from dynamically generated targets --- src/test/scala/hbt/StaticContextTests.scala | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/test/scala/hbt/StaticContextTests.scala (limited to 'src/test') diff --git a/src/test/scala/hbt/StaticContextTests.scala b/src/test/scala/hbt/StaticContextTests.scala new file mode 100644 index 00000000..022cfd1e --- /dev/null +++ b/src/test/scala/hbt/StaticContextTests.scala @@ -0,0 +1,36 @@ +package hbt + +import utest._ +class Helper{ + val static = implicitly[StaticContext] + object Nested { + val static = implicitly[StaticContext] + } + def method = implicitly[StaticContext] +} +object StaticContextTests extends TestSuite{ + val static = implicitly[StaticContext] + object Nested{ + val static = implicitly[StaticContext] + def method = implicitly[StaticContext] + class Helper{ + val static = implicitly[StaticContext] + } + } + + def method = implicitly[StaticContext] + val tests = Tests{ + val helper = new Helper() + 'inObject - assert(static.value) + 'inClass- assert(!helper.static.value) + 'inMethod - assert(!method.value) + + 'inObjectObject - assert(Nested.static.value) + 'inObjectClass- assert(!helper.static.value) + 'inObjectMethod- assert(!Nested.method.value) + + 'inClassObject - assert(!helper.Nested.static.value) + 'inClassMethod- assert(!helper.method.value) + + } +} -- cgit v1.2.3