summaryrefslogtreecommitdiff
path: root/scalatexApi/src/test/scala/scalatex/ParserTests.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-03 23:26:05 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-03 23:26:05 -0800
commit9d9cd46a6ccc5bbe8b22dc38f615b532e526774c (patch)
tree88e2c8c72209bcbe298b88a5bca5cd8e2bb986c7 /scalatexApi/src/test/scala/scalatex/ParserTests.scala
parent25d3233bae4ca89ba3a3916dfa9b45ee42d66435 (diff)
downloadhands-on-scala-js-9d9cd46a6ccc5bbe8b22dc38f615b532e526774c.tar.gz
hands-on-scala-js-9d9cd46a6ccc5bbe8b22dc38f615b532e526774c.tar.bz2
hands-on-scala-js-9d9cd46a6ccc5bbe8b22dc38f615b532e526774c.zip
Header blocks kinda implemented
Diffstat (limited to 'scalatexApi/src/test/scala/scalatex/ParserTests.scala')
-rw-r--r--scalatexApi/src/test/scala/scalatex/ParserTests.scala56
1 files changed, 38 insertions, 18 deletions
diff --git a/scalatexApi/src/test/scala/scalatex/ParserTests.scala b/scalatexApi/src/test/scala/scalatex/ParserTests.scala
index 45d6b50..f6d443f 100644
--- a/scalatexApi/src/test/scala/scalatex/ParserTests.scala
+++ b/scalatexApi/src/test/scala/scalatex/ParserTests.scala
@@ -81,17 +81,37 @@ object ParserTests extends utest.TestSuite{
}
'Code{
- * - check("@(1 + 1)lolsss\n", _.Code.run(), "(1 + 1)")
- * - check("@{{1} + (1)} ", _.Code.run(), "{{1} + (1)}")
- * - check("@{val x = 1; 1} ", _.Code.run(), "{val x = 1; 1}")
- * - check("@{`{}}{()@`}\n", _.Code.run(), "{`{}}{()@`}")
- * - check("@gggg ", _.Code.run(), "gggg")
+ 'identifier - check("@gggg ", _.Code.run(), "gggg")
+ 'parens - check("@(1 + 1)lolsss\n", _.Code.run(), "(1 + 1)")
+ 'curlies - check("@{{1} + (1)} ", _.Code.run(), "{{1} + (1)}")
+ 'blocks - check("@{val x = 1; 1} ", _.Code.run(), "{val x = 1; 1}")
+ 'weirdBackticks - check("@{`{}}{()@`}\n", _.Code.run(), "{`{}}{()@`}")
}
+ 'MiscCode{
+ 'imports{
+ * - check("@import math.abs", _.Header.run(), "import math.abs")
+ * - check("@import math.{abs, sin}", _.Header.run(), "import math.{abs, sin}")
+ }
+ 'headerblocks{
+ check(
+ """@import math.abs
+ |@import math.sin
+ |
+ |hello world
+ |""".stripMargin,
+ _.HeaderBlock.run(),
+ Ast.Block(
+ Some("import math.abs\nimport math.sin"),
+ Seq(Text("\n"), Text("hello world"), Text("\n"))
+ )
+ )
+ }
+ }
'Block{
- * - check("{i am a cow}", _.TBlock.run(), Block(Seq(Block.Text("i am a cow"))))
+ * - check("{i am a cow}", _.TBlock.run(), Block(None, Seq(Block.Text("i am a cow"))))
* - check("{i @am a @cow}", _.TBlock.run(),
- Block(Seq(
+ Block(None, Seq(
Block.Text("i "),
Chain("am",Seq()),
Block.Text(" a "),
@@ -111,10 +131,10 @@ object ParserTests extends utest.TestSuite{
)
* - check("@omg{bbq}.cow(moo){a @b}\n", _.ScalaChain.run(),
Chain("omg",Seq(
- Block(Seq(Block.Text("bbq"))),
+ Block(None, Seq(Block.Text("bbq"))),
Chain.Prop("cow"),
Chain.Args("(moo)"),
- Block(Seq(Block.Text("a "), Chain("b", Nil)))
+ Block(None, Seq(Block.Text("a "), Chain("b", Nil)))
))
)
}
@@ -126,13 +146,13 @@ object ParserTests extends utest.TestSuite{
| @bbq
| @lol""".stripMargin,
_.Body.run(),
- Block(Seq(
+ Block(None, Seq(
Text("\n"),
- Chain("omg",Seq(Block(Seq(
+ Chain("omg",Seq(Block(None, Seq(
Text("\n "),
- Chain("wtf",Seq(Block(Seq(
+ Chain("wtf",Seq(Block(None, Seq(
Text("\n "),
- Chain("bbq",Seq(Block(Seq(
+ Chain("bbq",Seq(Block(None, Seq(
Text("\n "),
Chain("lol",Seq())
))))
@@ -146,9 +166,10 @@ object ParserTests extends utest.TestSuite{
| @wtf
|@bbq""".stripMargin,
_.Body.run(),
- Block(Seq(
+ Block(None, Seq(
Text("\n"),
Chain("omg",Seq(Block(
+ None,
Seq(
Text("\n "),
Chain("wtf",Seq()))
@@ -163,11 +184,11 @@ object ParserTests extends utest.TestSuite{
| @wtf
|bbq""".stripMargin,
_.Body.run(),
- Block(Seq(
+ Block(None, Seq(
Text("\n"),
Chain("omg",Seq(
Args("""("lol", 1, 2)"""),
- Block(Seq(
+ Block(None, Seq(
Text("\n "),
Chain("wtf",Seq())))
)),
@@ -203,7 +224,7 @@ object ParserTests extends utest.TestSuite{
| omg * 2
|}""".stripMargin,
_.Body.run(),
- Block(Seq(
+ Block(None, Seq(
Text("\n"),
Chain("{\"lol\" * 3}", Seq()),
Text("\n"),
@@ -217,7 +238,6 @@ object ParserTests extends utest.TestSuite{
)
}
}
-
}