summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-05 22:39:39 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-05 22:39:39 -0800
commit652ebdfc8464c22647e0a84d1bcdcf9e9cb615b2 (patch)
tree3075dcb5ed00fa8d2e1f1b5e357cf32538cc8683
parentc6af197340ac1045afc1506a69a0bdf6f00fd595 (diff)
downloadhands-on-scala-js-652ebdfc8464c22647e0a84d1bcdcf9e9cb615b2.tar.gz
hands-on-scala-js-652ebdfc8464c22647e0a84d1bcdcf9e9cb615b2.tar.bz2
hands-on-scala-js-652ebdfc8464c22647e0a84d1bcdcf9e9cb615b2.zip
Most error tests pass except for lambdas
-rw-r--r--scalatexApi/src/main/scala/scalatex/stages/Compiler.scala5
-rw-r--r--scalatexApi/src/test/scala/scalatex/ErrorTests.scala134
2 files changed, 70 insertions, 69 deletions
diff --git a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
index f55c348..af474d0 100644
--- a/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
+++ b/scalatexApi/src/main/scala/scalatex/stages/Compiler.scala
@@ -73,10 +73,11 @@ object Compiler{
println("Tree " + res)
incPos(res, offset1)
res
- case Ast.Block.For(generators, Ast.Block(parts2, offset2), offset) =>
+ case Ast.Block.For(generators, Ast.Block(parts2, offset2), offset1) =>
val fresh = c.fresh()
- val tree = c.parse(s"$generators yield $fresh" )
+ val tree = incPosRec(c.parse(s"$generators yield $fresh"), offset1 + 2)
+
def rec(t: Tree): Tree = t match {
case a @ Apply(fun, List(f @ Function(vparams, body))) =>
val f2 = Function(vparams, rec(body))
diff --git a/scalatexApi/src/test/scala/scalatex/ErrorTests.scala b/scalatexApi/src/test/scala/scalatex/ErrorTests.scala
index 6ed1d31..9299380 100644
--- a/scalatexApi/src/test/scala/scalatex/ErrorTests.scala
+++ b/scalatexApi/src/test/scala/scalatex/ErrorTests.scala
@@ -196,7 +196,7 @@ object ErrorTests extends TestSuite{
// ^
// """
// )
-// }
+ }
'callContents{
* - check(
twRuntimeErrors("@scala.math.abs((1, 2).wtf)"),
@@ -295,79 +295,79 @@ object ErrorTests extends TestSuite{
)
}
}
-// 'forLoop{
-// 'oneLine{
+ 'forLoop{
+ 'oneLine{
'header - check(
twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"),
"""value omglolol is not a member of Int""",
"""
twRuntimeErrors("omg @for(x <- (0 + 1 + 2) omglolol (10 + 11 + 2)){ hello }"),
- ^
+ ^
"""
)
-//
-// 'body - check(
-// twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"),
-// """too many arguments for method +""",
-// """
-// twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"),
-// ^
-// """
-// )
-// }
-// 'multiLine{
-// 'body - check(
-// twRuntimeErrors("""
-// omg
-// @for(x <- 0 until 10)
-// I am cow hear me moo
-// I weigh twice as much as @x.kkk
-// """),
-// """value kkk is not a member of Int""",
-// """
-// I weigh twice as much as @x.kkk
-// ^
-// """
-// )
-// }
-// }
-// 'multiLine{
-// 'missingVar - check(
-// twRuntimeErrors("""
-// omg @notInScope lol
-// """),
-// """not found: value notInScope""",
-// """
-// omg @notInScope lol
-// ^
-// """
-// )
-// 'wrongType - check(
-// twRuntimeErrors("""
-// omg @{() => ()} lol
-// """),
-// """type mismatch""",
-// """
-// omg @{() => ()} lol
-// ^
-// """
-// )
-//
-// 'bigExpression - check(
-// twRuntimeErrors("""
-// @{
-// val x = 1 + 2
-// val y = new Object()
-// val z = y * x
-// x
-// }
-// """),
-// "value * is not a member of Object",
-// """
-// val z = y * x
-// ^
-// """
-// )
+
+ 'body - check(
+ twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"),
+ """too many arguments for method +""",
+ """
+ twRuntimeErrors("omg @for(x <- 0 until 10){ @((x, 2) + (1, 2)) }"),
+ ^
+ """
+ )
+ }
+ 'multiLine{
+ 'body - check(
+ twRuntimeErrors("""
+ omg
+ @for(x <- 0 until 10)
+ I am cow hear me moo
+ I weigh twice as much as @x.kkk
+ """),
+ """value kkk is not a member of Int""",
+ """
+ I weigh twice as much as @x.kkk
+ ^
+ """
+ )
+ }
+ }
+ 'multiLine{
+ 'missingVar - check(
+ twRuntimeErrors("""
+ omg @notInScope lol
+ """),
+ """not found: value notInScope""",
+ """
+ omg @notInScope lol
+ ^
+ """
+ )
+ 'wrongType - check(
+ twRuntimeErrors("""
+ omg @{() => ()} lol
+ """),
+ """type mismatch""",
+ """
+ omg @{() => ()} lol
+ ^
+ """
+ )
+
+ 'bigExpression - check(
+ twRuntimeErrors("""
+ @{
+ val x = 1 + 2
+ val y = new Object()
+ val z = y * x
+ x
+ }
+ """),
+ "value * is not a member of Object",
+ """
+ val z = y * x
+ ^
+ """
+ )
}
}
}