From 14ede69b487af5ebb8b0311a410f4d49dc66f540 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 5 Nov 2014 20:50:25 -0800 Subject: Refactored trim --- scalatexApi/src/main/scala/scalatex/package.scala | 2 +- .../src/main/scala/scalatex/stages/Parser.scala | 2 +- .../src/test/scala/scalatex/ErrorTests.scala | 264 ++++++++++----------- 3 files changed, 134 insertions(+), 134 deletions(-) diff --git a/scalatexApi/src/main/scala/scalatex/package.scala b/scalatexApi/src/main/scala/scalatex/package.scala index 1f00b72..78df45f 100644 --- a/scalatexApi/src/main/scala/scalatex/package.scala +++ b/scalatexApi/src/main/scala/scalatex/package.scala @@ -78,7 +78,7 @@ package object scalatex { def compile(s: String): c.Tree = { val realPos = new OffsetPosition(source, point).asInstanceOf[c.universe.Position] - Compiler(c)(realPos, Parser(stages.Trim.old(s))) + Compiler(c)(realPos, Parser.tupled(stages.Trim(s))) } diff --git a/scalatexApi/src/main/scala/scalatex/stages/Parser.scala b/scalatexApi/src/main/scala/scalatex/stages/Parser.scala index 45f82e0..d78ec8d 100644 --- a/scalatexApi/src/main/scala/scalatex/stages/Parser.scala +++ b/scalatexApi/src/main/scala/scalatex/stages/Parser.scala @@ -13,7 +13,7 @@ import Util._ */ object Parser extends ((String, Int) => Ast.Block){ def apply(input: String, offset: Int = 0): Ast.Block = { - new Parser(input).Body.run().get + new Parser(input, offset).Body.run().get } } class Parser(input: ParserInput, indent: Int = 0, offset: Int = 0) extends ScalaSyntax(input) { diff --git a/scalatexApi/src/test/scala/scalatex/ErrorTests.scala b/scalatexApi/src/test/scala/scalatex/ErrorTests.scala index 7b40c40..82976eb 100644 --- a/scalatexApi/src/test/scala/scalatex/ErrorTests.scala +++ b/scalatexApi/src/test/scala/scalatex/ErrorTests.scala @@ -30,124 +30,124 @@ object ErrorTests extends TestSuite{ val tests = TestSuite{ -// 'simple - check( -// twRuntimeErrors("omg @notInScope lol"), -// """not found: value notInScope""", -// """ -// twRuntimeErrors("omg @notInScope lol"), -// ^ -// """ -// ) -// + 'simple - check( + twRuntimeErrors("omg @notInScope lol"), + """not found: value notInScope""", + """ + twRuntimeErrors("omg @notInScope lol"), + ^ + """ + ) + // 'chained{ 'properties { -// * - check( -// twRuntimeErrors("omg @math.lol lol"), -// """object lol is not a member of package math""", -// """ -// twRuntimeErrors("omg @math.lol lol"), -// ^ -// """ -// ) -// -// * - check( -// twRuntimeErrors("omg @math.E.lol lol"), -// """value lol is not a member of Double""", -// """ -// twRuntimeErrors("omg @math.E.lol lol"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("omg @_root_.scala.math.lol lol"), -// """object lol is not a member of package math""", -// """ -// twRuntimeErrors("omg @_root_.scala.math.lol lol"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("omg @_root_.scala.gg.lol lol"), -// """object gg is not a member of package scala""", -// """ -// twRuntimeErrors("omg @_root_.scala.gg.lol lol"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), -// """object ggnore is not a member of package """, -// """ -// twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), -// ^ -// """ -// ) -// } -// 'calls{ -// * - check( -// twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), -// """object QQ is not a member of package scala""", -// """ -// twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), -// "value tdo is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), -// "value z is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), -// "value z is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), -// "value cow is not a member of Int", -// """ -// twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.smath.abs.cow.sum.z"), -// "object smath is not a member of package scala", -// """ -// twRuntimeErrors("@scala.smath.abs.cow.sum.z"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.cos('omg)"), -// "type mismatch", -// """ -// twRuntimeErrors("@scala.math.cos('omg)"), -// ^ -// """ -// ) -// * - check( -// twRuntimeErrors("@scala.math.cos[omg]('omg)"), -// "not found: type omg", -// """ -// twRuntimeErrors("@scala.math.cos[omg]('omg)"), -// ^ -// """ -// ) + * - check( + twRuntimeErrors("omg @math.lol lol"), + """object lol is not a member of package math""", + """ + twRuntimeErrors("omg @math.lol lol"), + ^ + """ + ) + + * - check( + twRuntimeErrors("omg @math.E.lol lol"), + """value lol is not a member of Double""", + """ + twRuntimeErrors("omg @math.E.lol lol"), + ^ + """ + ) + * - check( + twRuntimeErrors("omg @_root_.scala.math.lol lol"), + """object lol is not a member of package math""", + """ + twRuntimeErrors("omg @_root_.scala.math.lol lol"), + ^ + """ + ) + * - check( + twRuntimeErrors("omg @_root_.scala.gg.lol lol"), + """object gg is not a member of package scala""", + """ + twRuntimeErrors("omg @_root_.scala.gg.lol lol"), + ^ + """ + ) + * - check( + twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), + """object ggnore is not a member of package """, + """ + twRuntimeErrors("omg @_root_.ggnore.math.lol lol"), + ^ + """ + ) + } + 'calls{ + * - check( + twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), + """object QQ is not a member of package scala""", + """ + twRuntimeErrors("@scala.QQ.abs(-10).tdo(10).sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), + "value tdo is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).tdo(10).sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), + "value z is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), + "value z is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).to(10).sum.z()"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), + "value cow is not a member of Int", + """ + twRuntimeErrors("@scala.math.abs(-10).cow.sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.smath.abs.cow.sum.z"), + "object smath is not a member of package scala", + """ + twRuntimeErrors("@scala.smath.abs.cow.sum.z"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.cos('omg)"), + "type mismatch", + """ + twRuntimeErrors("@scala.math.cos('omg)"), + ^ + """ + ) + * - check( + twRuntimeErrors("@scala.math.cos[omg]('omg)"), + "not found: type omg", + """ + twRuntimeErrors("@scala.math.cos[omg]('omg)"), + ^ + """ + ) * - check( twRuntimeErrors(""" I am cow hear me moo @@ -162,23 +162,23 @@ object ErrorTests extends TestSuite{ ) } // 'curlies{ -// * - check( -// twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), -// "missing arguments for method foldLeft", -// """ -// twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), -// ^ -// """ -// ) + * - check( + twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), + "missing arguments for method foldLeft", + """ + twRuntimeErrors("@p{@Seq(1, 2, 3).foldLeft(0)}"), + ^ + """ + ) // -// * - check( -// twRuntimeErrors("@Nil.foldLeft{XY}"), -// "missing arguments for method foldLeft", -// """ -// twRuntimeErrors("@Nil.foldLeft{XY}"), -// ^ -// """ -// ) + * - check( + twRuntimeErrors("@Nil.foldLeft{XY}"), + "missing arguments for method foldLeft", + """ + twRuntimeErrors("@Nil.foldLeft{XY}"), + ^ + """ + ) // // * - check( // twRuntimeErrors("@Nil.map{(x: Int, y: String) => omg}"), -- cgit v1.2.3