summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi@dropbox.com>2014-11-16 19:18:01 -0800
committerLi Haoyi <haoyi@dropbox.com>2014-11-16 19:18:01 -0800
commit498585ce96837f815233be946902e8fd4802f9c9 (patch)
tree24e4ba89b937e43b1e1b28e689eef45ab7768c5d
parentdb544916874accf7d2a90f6f6d95a30cf88588c6 (diff)
downloadhands-on-scala-js-498585ce96837f815233be946902e8fd4802f9c9.tar.gz
hands-on-scala-js-498585ce96837f815233be946902e8fd4802f9c9.tar.bz2
hands-on-scala-js-498585ce96837f815233be946902e8fd4802f9c9.zip
Turned on Trim.scala test
-rw-r--r--scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala40
1 files changed, 38 insertions, 2 deletions
diff --git a/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala b/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala
index d9f4820..6378eb0 100644
--- a/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala
+++ b/scalatexApi/src/test/scala/scalaparser/SyntaxTest.scala
@@ -180,6 +180,41 @@ object SyntaxTest extends TestSuite{
|}
""".stripMargin
)
+// * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/stages/Trim.scala").mkString)
+// * - check(
+// """
+// |package scalatex.stages
+// |import acyclic.file
+// |
+// |/**
+// | * Preprocesses the input string to normalize things related to whitespace
+// | *
+// | * Find the "first" non-whitespace-line of the text and remove the front
+// | * of every line to align that first line with the left margin.
+// | *
+// | * Remove all trailing whitespace from each line.
+// | */
+// |object Trim extends (String => (String, Int)){
+// | def apply(str: String) = {
+// | val lines = str.split("\n", -1)
+// | val offset = lines.iterator
+// | .filter(_.length > 0)
+// | .next()
+// | .takeWhile(_ == ' ')
+// | .length
+// | val res = lines.iterator
+// | .map(_.replaceFirst("\\s+$", ""))
+// | .mkString("\n")
+// | (res, offset)
+// | }
+// | def old(str: String) = {
+// | val (res, offset) = this.apply(str)
+// | res.split("\n", -1).map(_.drop(offset)).mkString("\n")
+// | }
+// |}
+// |
+// """.stripMargin
+// )
}
'file{
def checkFile(path: String) =
@@ -195,8 +230,9 @@ object SyntaxTest extends TestSuite{
// * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/stages/Compiler.scala").mkString)
- * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/stages/Parser.scala").mkString) // * - check(io.Source.fromFile("scalatexApi/src/test/scala/scalatex/ParserTests.scala").mkString)
- // * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/stages/Trim.scala").mkString)
+ * - checkFile("scalatexApi/src/main/scala/scalatex/stages/Parser.scala")
+ // * - check(io.Source.fromFile("scalatexApi/src/test/scala/scalatex/ParserTests.scala").mkString)
+ * - checkFile("scalatexApi/src/main/scala/scalatex/stages/Trim.scala")
// * - check(io.Source.fromFile("scalatexApi/src/main/scala/scalatex/package.scala").mkString)
}