summaryrefslogtreecommitdiff
path: root/core/src/test/scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-04 23:12:41 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-04 23:12:41 -0700
commit7cd2b7ef3d367a5638cf6ae1fdc62f0bee466f8e (patch)
tree5aff15c4b83015e7c18e11d1093e7baa99d9bc1c /core/src/test/scala
parente1f8bc965bbf0c66cf372f5c81295a4c12fafc7d (diff)
downloadmill-7cd2b7ef3d367a5638cf6ae1fdc62f0bee466f8e.tar.gz
mill-7cd2b7ef3d367a5638cf6ae1fdc62f0bee466f8e.tar.bz2
mill-7cd2b7ef3d367a5638cf6ae1fdc62f0bee466f8e.zip
Split out `MacroErrorTests` into it's own file
Diffstat (limited to 'core/src/test/scala')
-rw-r--r--core/src/test/scala/forge/CacherTests.scala53
-rw-r--r--core/src/test/scala/forge/MacroErrorTests.scala63
2 files changed, 63 insertions, 53 deletions
diff --git a/core/src/test/scala/forge/CacherTests.scala b/core/src/test/scala/forge/CacherTests.scala
index 11ecdfce..4c346e5e 100644
--- a/core/src/test/scala/forge/CacherTests.scala
+++ b/core/src/test/scala/forge/CacherTests.scala
@@ -46,58 +46,5 @@ object CacherTests extends TestSuite{
eval(Terminal, Terminal.value) == 7,
eval(Terminal, Terminal.overriden) == 1
)
- 'errors{
- val expectedMsg =
- "T{} members defined in a Cacher class/trait/object body must be defs"
-
- val err = compileError("object Foo extends Target.Cacher{ val x = T{1} }")
- assert(err.msg == expectedMsg)
- }
- 'badTmacro - {
- // Make sure we can reference values from outside the T{...} block as part
- // of our `Target#apply()` calls, but we cannot reference any values that
- // come from inside the T{...} block
- 'pos - {
- val a = T{ 1 }
- val arr = Array(a)
- val b = {
- val c = 0
- T{
- arr(c)()
- }
- }
- }
- 'neg - {
-
- val expectedMsg =
- "Target#apply() call cannot use `value n` defined within the T{...} block"
- val err = compileError("""{
- val a = T{ 1 }
- val arr = Array(a)
- val b = {
- T{
- val n = 0
- arr(n)()
- }
- }
- }""")
- assert(err.msg == expectedMsg)
- }
- 'neg2 - {
-
- val expectedMsg =
- "Target#apply() call cannot use `value x` defined within the T{...} block"
- val err = compileError("""{
- val a = T{ 1 }
- val arr = Array(a)
- val b = {
- T{
- arr.map{x => x()}
- }
- }
- }""")
- assert(err.msg == expectedMsg)
- }
- }
}
}
diff --git a/core/src/test/scala/forge/MacroErrorTests.scala b/core/src/test/scala/forge/MacroErrorTests.scala
new file mode 100644
index 00000000..29f68f4d
--- /dev/null
+++ b/core/src/test/scala/forge/MacroErrorTests.scala
@@ -0,0 +1,63 @@
+package forge
+
+import utest._
+
+object MacroErrorTests extends TestSuite{
+
+ val tests = Tests{
+
+ 'errors{
+ val expectedMsg =
+ "T{} members defined in a Cacher class/trait/object body must be defs"
+
+ val err = compileError("object Foo extends Target.Cacher{ val x = T{1} }")
+ assert(err.msg == expectedMsg)
+ }
+ 'badTmacro - {
+ // Make sure we can reference values from outside the T{...} block as part
+ // of our `Target#apply()` calls, but we cannot reference any values that
+ // come from inside the T{...} block
+ 'pos - {
+ val a = T{ 1 }
+ val arr = Array(a)
+ val b = {
+ val c = 0
+ T{
+ arr(c)()
+ }
+ }
+ }
+ 'neg - {
+
+ val expectedMsg =
+ "Target#apply() call cannot use `value n` defined within the T{...} block"
+ val err = compileError("""{
+ val a = T{ 1 }
+ val arr = Array(a)
+ val b = {
+ T{
+ val n = 0
+ arr(n)()
+ }
+ }
+ }""")
+ assert(err.msg == expectedMsg)
+ }
+ 'neg2 - {
+
+ val expectedMsg =
+ "Target#apply() call cannot use `value x` defined within the T{...} block"
+ val err = compileError("""{
+ val a = T{ 1 }
+ val arr = Array(a)
+ val b = {
+ T{
+ arr.map{x => x()}
+ }
+ }
+ }""")
+ assert(err.msg == expectedMsg)
+ }
+ }
+ }
+}