summaryrefslogtreecommitdiff
path: root/scalatexApi/src/test/scala/scalatex/ParserTests.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-04 22:13:05 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-04 22:13:05 -0800
commita99ca0a1c4df83638d888d316a453b6516477a08 (patch)
treeea8be36353210826660582a9a2d11748c79d594b /scalatexApi/src/test/scala/scalatex/ParserTests.scala
parent938c026bef8d4ce10848831479944642ac6da853 (diff)
downloadhands-on-scala-js-a99ca0a1c4df83638d888d316a453b6516477a08.tar.gz
hands-on-scala-js-a99ca0a1c4df83638d888d316a453b6516477a08.tar.bz2
hands-on-scala-js-a99ca0a1c4df83638d888d316a453b6516477a08.zip
Narrowed it down to a problem in parboiled2??? It seem like if "f" gets printed, "B" should get printed too...
Diffstat (limited to 'scalatexApi/src/test/scala/scalatex/ParserTests.scala')
-rw-r--r--scalatexApi/src/test/scala/scalatex/ParserTests.scala119
1 files changed, 69 insertions, 50 deletions
diff --git a/scalatexApi/src/test/scala/scalatex/ParserTests.scala b/scalatexApi/src/test/scala/scalatex/ParserTests.scala
index c012328..5cefa67 100644
--- a/scalatexApi/src/test/scala/scalatex/ParserTests.scala
+++ b/scalatexApi/src/test/scala/scalatex/ParserTests.scala
@@ -4,7 +4,7 @@ package scalatex
import org.parboiled2._
import torimatomeru.ScalaSyntax
-import scalatex.stages.{Parser, Ast}
+import scalatex.stages.{Trim, Parser, Ast}
import scalatex.stages.Ast.Block.{IfElse, For, Text}
import Ast.Chain.Args
@@ -149,57 +149,76 @@ object ParserTests extends utest.TestSuite{
)
}
'ControlFlow{
- 'for - check(
- "@for(x <- 0 until 3){lol}",
- _.ForLoop.run(),
- For("for(x <- 0 until 3)", Block(Seq(Text("lol"))))
- )
- 'forBlock - check(
- """@for(x <- 0 until 3)
- | lol""".stripMargin,
- _.LoneForLoop.run(),
- For("for(x <- 0 until 3)", Block(Seq(Text("\n "), Text("lol"))))
- )
- 'if - check(
- "@if(true){lol}",
- _.IfElse.run(),
- IfElse("if(true)", Block(Seq(Text("lol"))), None)
- )
- 'ifElse - check(
- "@if(true){lol}else{ omg }",
- _.IfElse.run(),
- IfElse("if(true)", Block(Seq(Text("lol"))), Some(Block(Seq(Text(" omg ")))))
- )
- 'ifBlock- check(
- """@if(true)
- | omg""".stripMargin,
- _.IfElse.run(),
- IfElse("if(true)", Block(Seq(Text("\n "), Text("omg"))), None)
- )
- 'ifBlockElseBlock - check(
- """@if(true)
- | omg
- |@else
- | wtf""".stripMargin,
- _.IfElse.run(),
- IfElse(
- "if(true)",
- Block(Seq(Text("\n "), Text("omg"))),
- Some(Block(Seq(Text("\n "), Text("wtf"))))
+ 'for {
+ 'for - check(
+ "@for(x <- 0 until 3){lol}",
+ _.ForLoop.run(),
+ For("for(x <- 0 until 3)", Block(Seq(Text("lol"))))
)
- )
- 'ifElseBlock - check(
- """@if(true){
- | omg
- |}else
- | wtf""".stripMargin,
- _.IfElse.run(),
- IfElse(
- "if(true)",
- Block(Seq(Text("\n "), Text("omg"), Text("\n"))),
- Some(Block(Seq(Text("\n "), Text("wtf"))))
+ 'forBlock - check(
+ """
+ |@for(x <- 0 until 3)
+ | lol""".stripMargin,
+ _.Body.run(),
+ Block(Seq(
+ Text("\n"),
+ For("for(x <- 0 until 3)", Block(Seq(Text("\n "), Text("lol"))))
+ ))
)
- )
+ 'forBlockBraces - check(
+ """
+ |@for(x <- 0 until 3){
+ | lol
+ |}""".stripMargin,
+ _.Body.run(),
+ Block(Seq(
+ Text("\n"),
+ For("for(x <- 0 until 3)", Block(Seq(Text("\n "), Text("lol"))))
+ ))
+ )
+ }
+ 'ifElse {
+ 'if - check(
+ "@if(true){lol}",
+ _.IfElse.run(),
+ IfElse("if(true)", Block(Seq(Text("lol"))), None)
+ )
+ 'ifElse - check(
+ "@if(true){lol}else{ omg }",
+ _.IfElse.run(),
+ IfElse("if(true)", Block(Seq(Text("lol"))), Some(Block(Seq(Text(" omg ")))))
+ )
+ 'ifBlock - check(
+ """@if(true)
+ | omg""".stripMargin,
+ _.IfElse.run(),
+ IfElse("if(true)", Block(Seq(Text("\n "), Text("omg"))), None)
+ )
+ 'ifBlockElseBlock - check(
+ """@if(true)
+ | omg
+ |@else
+ | wtf""".stripMargin,
+ _.IfElse.run(),
+ IfElse(
+ "if(true)",
+ Block(Seq(Text("\n "), Text("omg"))),
+ Some(Block(Seq(Text("\n "), Text("wtf"))))
+ )
+ )
+ 'ifElseBlock - check(
+ """@if(true){
+ | omg
+ |}else
+ | wtf""".stripMargin,
+ _.IfElse.run(),
+ IfElse(
+ "if(true)",
+ Block(Seq(Text("\n "), Text("omg"), Text("\n"))),
+ Some(Block(Seq(Text("\n "), Text("wtf"))))
+ )
+ )
+ }
}
'Body{
'indents - check(