diff --git a/build.sbt b/build.sbt index 44e0b59d..beffec2c 100644 --- a/build.sbt +++ b/build.sbt @@ -76,6 +76,8 @@ pomExtra := ( ) +libraryDependencies ++= Seq("junit" % "junit" % "4.11" % "test", "com.novocode" % "junit-interface" % "0.10" % "test") + // default value must be set here TestKeys.includeTestDependencies := true diff --git a/src/test/scala/scala/util/parsing/combinator/JavaTokenParsersTest.scala b/src/test/scala/scala/util/parsing/combinator/JavaTokenParsersTest.scala new file mode 100644 index 00000000..5851a655 --- /dev/null +++ b/src/test/scala/scala/util/parsing/combinator/JavaTokenParsersTest.scala @@ -0,0 +1,58 @@ +package scala.util.parsing.combinator + +import scala.util.parsing.input.CharArrayReader + +import org.junit.Test +import org.junit.Assert.assertEquals + +class JavaTokenParsersTest { + + @Test + def parseDecimalNumber: Unit = { + object TestJavaTokenParsers extends JavaTokenParsers + import TestJavaTokenParsers._ + assertEquals("1.1", decimalNumber(new CharArrayReader("1.1".toCharArray)).get) + assertEquals("1.", decimalNumber(new CharArrayReader("1.".toCharArray)).get) + assertEquals(".1", decimalNumber(new CharArrayReader(".1".toCharArray)).get) + // should fail to parse and we should get Failure as ParseResult + val failure = decimalNumber(new CharArrayReader("!1".toCharArray)).asInstanceOf[Failure] + assertEquals("""string matching regex `(\d+(\.\d*)?|\d*\.\d+)' expected but `!' found""", failure.msg) + } + + @Test + def parseJavaIdent: Unit = { + object javaTokenParser extends JavaTokenParsers + import javaTokenParser._ + def parseSuccess(s: String): Unit = { + val parseResult = parseAll(ident, s) + parseResult match { + case Success(r, _) => assertEquals(s, r) + case _ => sys.error(parseResult.toString) + } + } + def parseFailure(s: String, errorColPos: Int): Unit = { + val parseResult = parseAll(ident, s) + parseResult match { + case Failure(_, next) => + val pos = next.pos + assertEquals(1, pos.line) + assertEquals(errorColPos, pos.column) + case _ => sys.error(parseResult.toString) + } + } + parseSuccess("simple") + parseSuccess("with123") + parseSuccess("with$") + parseSuccess("with\u00f8\u00df\u00f6\u00e8\u00e6") + parseSuccess("with_") + parseSuccess("_with") + + parseFailure("3start", 1) + parseFailure("-start", 1) + parseFailure("with-s", 5) + // we♥scala + parseFailure("we\u2665scala", 3) + parseFailure("with space", 6) + } + +} diff --git a/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala b/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala new file mode 100644 index 00000000..e63acd0e --- /dev/null +++ b/src/test/scala/scala/util/parsing/combinator/PackratParsersTest.scala @@ -0,0 +1,159 @@ +package scala.util.parsing.combinator + +import org.junit.Test +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue + +import scala.util.parsing.combinator.syntactical.StandardTokenParsers + +class PackratParsersTest { + + @Test + def test1: Unit = { + import grammars1._ + val head = phrase(term) + + def extractResult(r : ParseResult[Int]): Int = r match { + case Success(a,_) => a + case NoSuccess(a,_) => sys.error(a) + } + def check(expected: Int, expr: String): Unit = { + val parseResult = head(new lexical.Scanner(expr)) + val result = extractResult(parseResult) + assertEquals(expected, result) + } + + check(1, "1") + check(3, "1+2") + check(5, "9-4") + check(81, "9*9") + check(4, "8/2") + check(37, "4*9-0/7+9-8*1") + check(9, "(1+2)*3") + } + + @Test + def test2: Unit = { + import grammars2._ + val head = phrase(exp) + + def extractResult(r : ParseResult[Int]): Int = r match { + case Success(a,_) => a + case NoSuccess(a,_) => sys.error(a) + } + def check(expected: Int, expr: String): Unit = { + val parseResult = head(new lexical.Scanner(expr)) + val result = extractResult(parseResult) + assertEquals(expected, result) + } + + check(1, "1") + check(3, "1+2") + check(81, "9*9") + check(43, "4*9+7") + check(59, "4*9+7*2+3*3") + check(188, "4*9+7*2+3*3+9*5+7*6*2") + check(960, "4*(9+7)*(2+3)*3") + } + + @Test + def test3: Unit = { + import grammars3._ + val head = phrase(AnBnCn) + def extractResult(r: ParseResult[AnBnCnResult]): AnBnCnResult = r match { + case Success(a,_) => a + case NoSuccess(a,_) => sys.error(a) + } + def threeLists(as: List[Symbol], bs: List[Symbol], cs: List[Symbol]): AnBnCnResult = { + val as1 = as.map(_.name) + val bs1 = bs.map(_.name) + val cs1 = cs.map(_.name) + new ~(new ~(as1, bs1), cs1) + } + def assertSuccess(expected1: List[Symbol], expected2: List[Symbol], expected3: List[Symbol], + input: String): Unit = { + val expected = threeLists(expected1, expected2, expected3) + val parseResult = head(new lexical.Scanner(input)) + val result = extractResult(parseResult) + assertEquals(expected, result) + } + + assertSuccess(List('a, 'b), List('a), List('b, 'c), "a b c") + assertSuccess(List('a, 'a, 'b, 'b), List('a, 'a), List('b, 'b, 'c, 'c), "a a b b c c") + assertSuccess(List('a, 'a, 'a, 'b, 'b, 'b), List('a, 'a, 'a), List('b, 'b, 'b, 'c, 'c, 'c), + "a a a b b b c c c") + assertSuccess(List('a, 'a, 'a, 'a, 'b, 'b, 'b, 'b), List('a, 'a, 'a, 'a), List('b, 'b, 'b, 'b, 'c, 'c, 'c, 'c), + "a a a a b b b b c c c c") + + def assertFailure(expectedFailureMsg: String, input: String): Unit = { + val packratReader = new PackratReader(new lexical.Scanner(input)) + val parseResult = AnBnCn(packratReader) + assertTrue(s"Not an instance of Failure: ${parseResult.toString()}", parseResult.isInstanceOf[Failure]) + val failure = parseResult.asInstanceOf[Failure] + assertEquals(expectedFailureMsg, failure.msg) + } + assertFailure("``b'' expected but `c' found", "a a a a b b b c c c c") + assertFailure("end of input", "a a a a b b b b c c c") + } + +} + +private object grammars1 extends StandardTokenParsers with PackratParsers { + + lexical.delimiters ++= List("+","-","*","/","(",")") + lexical.reserved ++= List("Hello","World") + + /**** + * term = term + fact | term - fact | fact + * fact = fact * num | fact / num | num + */ + + + val term: PackratParser[Int] = (term~("+"~>fact) ^^ {case x~y => x+y} + |term~("-"~>fact) ^^ {case x~y => x-y} + |fact) + + val fact: PackratParser[Int] = (fact~("*"~>numericLit) ^^ {case x~y => x*y.toInt} + |fact~("/"~>numericLit) ^^ {case x~y => x/y.toInt} + |"("~>term<~")" + |numericLit ^^ {_.toInt}) +} + +private object grammars2 extends StandardTokenParsers with PackratParsers { + + lexical.delimiters ++= List("+","-","*","/","(",")") + lexical.reserved ++= List("Hello","World") + + /* + * exp = sum | prod | num + * sum = exp ~ "+" ~ num + * prod = exp ~ "*" ~ num + */ + + val exp : PackratParser[Int] = sum | prod | numericLit ^^{_.toInt} | "("~>exp<~")" + val sum : PackratParser[Int] = exp~("+"~>exp) ^^ {case x~y => x+y} + val prod: PackratParser[Int] = exp~("*"~>(numericLit ^^{_.toInt} | exp)) ^^ {case x~y => x*y} + +} + +private object grammars3 extends StandardTokenParsers with PackratParsers { + lexical.reserved ++= List("a","b", "c") + val a: PackratParser[String] = memo("a") + val b: PackratParser[String] = memo("b") + val c: PackratParser[String] = memo("c") + + type AnBnCnResult = List[String] ~ List[String] ~ List[String] + + val AnBnCn: PackratParser[AnBnCnResult] = + guard(repMany1(a,b) <~ not(b)) ~ rep1(a) ~ repMany1(b,c)// ^^{case x~y => x:::y} + + + private def repMany[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = + ( p~repMany(p,q)~q ^^ {case x~xs~y => x::xs:::(y::Nil)} + | success(Nil) + ) + + def repMany1[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = + p~opt(repMany(p,q))~q ^^ {case x~Some(xs)~y => x::xs:::(y::Nil)} + +} diff --git a/src/test/scala/scala/util/parsing/combinator/RegexParsersTest.scala b/src/test/scala/scala/util/parsing/combinator/RegexParsersTest.scala new file mode 100644 index 00000000..f894af3f --- /dev/null +++ b/src/test/scala/scala/util/parsing/combinator/RegexParsersTest.scala @@ -0,0 +1,76 @@ +package scala.util.parsing.combinator + +import org.junit.Test +import org.junit.Assert.assertEquals + +class RegexParsersTest { + @Test + def parserNoSuccessMessage: Unit = { + object parser extends RegexParsers { + def sign = "-" + def number = "\\d+".r + type ResultType = Option[String] ~ String + def p: Parser[ResultType] = sign.? ~ number withErrorMessage "Number expected!" + def q: Parser[ResultType] = sign.? ~! number withErrorMessage "Number expected!" + } + import parser._ + def extractResult(r: ParseResult[ResultType]): ResultType = r match { + case Success(r, _) => r + case r => sys.error(r.toString) + } + def result(num: Int): ResultType = { + val minusSign = if (num < 0) Some("-") else None + val absNumStr = Math.abs(num).toString + new ~(minusSign, absNumStr) + } + + val failure1 = parseAll(p, "-x").asInstanceOf[Failure] + assertEquals("string matching regex `\\d+' expected but `x' found", failure1.msg) + val failure2 = parseAll(p, "x").asInstanceOf[Failure] + assertEquals("string matching regex `\\d+' expected but `x' found", failure2.msg) + assertEquals(result(-5), extractResult(parseAll(p, "-5"))) + assertEquals(result(5), extractResult(parseAll(p, "5"))) + val error1 = parseAll(q, "-x").asInstanceOf[Error] + assertEquals("Number expected!", error1.msg) + val error2 = parseAll(q, "x").asInstanceOf[Error] + assertEquals("Number expected!", error2.msg) + assertEquals(result(-5), extractResult(parseAll(q, "-5"))) + assertEquals(result(5), extractResult(parseAll(q, "5"))) + } + + @Test + def parserFilter: Unit = { + object parser extends RegexParsers { + val keywords = Set("if", "false") + def word: Parser[String] = "\\w+".r + + def keyword: Parser[String] = word filter (keywords.contains) + def ident: Parser[String] = word filter(!keywords.contains(_)) + + def test: Parser[String ~ String] = keyword ~ ident + } + import parser._ + + val failure1 = parseAll(test, "if false").asInstanceOf[Failure] + assertEquals("Input doesn't match filter: false", failure1.msg) + val failure2 = parseAll(test, "not true").asInstanceOf[Failure] + assertEquals("Input doesn't match filter: not", failure2.msg) + val success = parseAll(test, "if true").asInstanceOf[Success[String ~ String]] + assertEquals(new ~("if", "true"), success.get) + } + + @Test + def parserForFilter: Unit = { + object parser extends RegexParsers { + def word: Parser[String] = "\\w+".r + + def twoWords = for { + (a ~ b) <- word ~ word + } yield (b, a) + } + import parser._ + + val success = parseAll(twoWords, "first second").asInstanceOf[Success[(String, String)]] + assertEquals(("second", "first"), success.get) + } +} diff --git a/test/files/run/jtptest.check b/test/files/run/jtptest.check deleted file mode 100644 index 95dbd284..00000000 --- a/test/files/run/jtptest.check +++ /dev/null @@ -1,7 +0,0 @@ -[1.4] parsed: 1.1 -[1.3] parsed: 1. -[1.3] parsed: .1 -[1.1] failure: string matching regex `(\d+(\.\d*)?|\d*\.\d+)' expected but `!' found - -!1 -^ diff --git a/test/files/run/jtptest.scala b/test/files/run/jtptest.scala deleted file mode 100644 index 4d0eef91..00000000 --- a/test/files/run/jtptest.scala +++ /dev/null @@ -1,17 +0,0 @@ - -import scala.util.parsing.combinator.JavaTokenParsers -import scala.util.parsing.input.CharArrayReader - -object TestJavaTokenParsers extends JavaTokenParsers { -} - -object Test { - import TestJavaTokenParsers._ - - def main(args : Array[String]) { - println(decimalNumber(new CharArrayReader("1.1".toCharArray))) - println(decimalNumber(new CharArrayReader("1.".toCharArray))) - println(decimalNumber(new CharArrayReader(".1".toCharArray))) - println(decimalNumber(new CharArrayReader("!1".toCharArray))) - } -} diff --git a/test/files/run/packrat1.check b/test/files/run/packrat1.check deleted file mode 100644 index e9f797e1..00000000 --- a/test/files/run/packrat1.check +++ /dev/null @@ -1,7 +0,0 @@ -1 -3 -5 -81 -4 -37 -9 diff --git a/test/files/run/packrat1.scala b/test/files/run/packrat1.scala deleted file mode 100644 index b5a46873..00000000 --- a/test/files/run/packrat1.scala +++ /dev/null @@ -1,47 +0,0 @@ -import scala.util.parsing.combinator._ - -import scala.util.parsing.combinator.syntactical.StandardTokenParsers -import scala.util.parsing.input._ -import scala.util.parsing.combinator.token._ - -import scala.collection.mutable.HashMap - -object Test extends App{ - import grammars._ - - val head = phrase(term) - - println(extractResult(head(new lexical.Scanner("1")))) - println(extractResult(head(new lexical.Scanner("1+2")))) - println(extractResult(head(new lexical.Scanner("9-4")))) - println(extractResult(head(new lexical.Scanner("9*9")))) - println(extractResult(head(new lexical.Scanner("8/2")))) - println(extractResult(head(new lexical.Scanner("4*9-0/7+9-8*1")))) - println(extractResult(head(new lexical.Scanner("(1+2)*3")))) -} - -object grammars extends StandardTokenParsers with PackratParsers{ - - def extractResult(r : ParseResult[_]) = r match { - case Success(a,_) => a - case NoSuccess(a,_) => a - } - - lexical.delimiters ++= List("+","-","*","/","(",")") - lexical.reserved ++= List("Hello","World") - - /**** - * term = term + fact | term - fact | fact - * fact = fact * num | fact / num | num - */ - - - val term: PackratParser[Int] = (term~("+"~>fact) ^^ {case x~y => x+y} - |term~("-"~>fact) ^^ {case x~y => x-y} - |fact) - - val fact: PackratParser[Int] = (fact~("*"~>numericLit) ^^ {case x~y => x*y.toInt} - |fact~("/"~>numericLit) ^^ {case x~y => x/y.toInt} - |"("~>term<~")" - |numericLit ^^ {_.toInt}) - } diff --git a/test/files/run/packrat2.check b/test/files/run/packrat2.check deleted file mode 100644 index 55a32ac5..00000000 --- a/test/files/run/packrat2.check +++ /dev/null @@ -1,7 +0,0 @@ -1 -3 -81 -43 -59 -188 -960 diff --git a/test/files/run/packrat2.scala b/test/files/run/packrat2.scala deleted file mode 100644 index f55021a6..00000000 --- a/test/files/run/packrat2.scala +++ /dev/null @@ -1,57 +0,0 @@ -import scala.util.parsing.combinator._ - -import scala.util.parsing.combinator.syntactical.StandardTokenParsers -import scala.util.parsing.input._ -import scala.util.parsing.combinator.token._ - -import scala.collection.mutable.HashMap - -object Test extends App{ - import grammars2._ - - val head = phrase(exp) - - println(extractResult(head(new lexical.Scanner("1")))) - println(extractResult(head(new lexical.Scanner("1+2")))) - println(extractResult(head(new lexical.Scanner("9*9")))) - println(extractResult(head(new lexical.Scanner("4*9+7")))) - println(extractResult(head(new lexical.Scanner("4*9+7*2+3*3")))) - println(extractResult(head(new lexical.Scanner("4*9+7*2+3*3+9*5+7*6*2")))) - println(extractResult(head(new lexical.Scanner("4*(9+7)*(2+3)*3")))) - -} - -object grammars2 extends StandardTokenParsers with PackratParsers{ - - def extractResult(r : ParseResult[_]) = r match{ - case Success(a,_) => a - case NoSuccess(a,_) => a - } - - lexical.delimiters ++= List("+","-","*","/","(",")") - lexical.reserved ++= List("Hello","World") - - /* - * exp = sum | prod | num - * sum = exp ~ "+" ~ num - * prod = exp ~ "*" ~ num - */ - - val exp : PackratParser[Int] = sum | prod | numericLit ^^{_.toInt} | "("~>exp<~")" - val sum : PackratParser[Int] = exp~("+"~>exp) ^^ {case x~y => x+y} - val prod: PackratParser[Int] = exp~("*"~>(numericLit ^^{_.toInt} | exp)) ^^ {case x~y => x*y} - - - /* lexical.reserved ++= List("a","b", "c") - val a : PackratParser[Any] = numericLit^^{x => primeFactors(x.toInt)} - val b : PackratParser[Any] = memo("b") - val c : PackratParser[Any] = memo("c") - val AnBnCn : PackratParser[Any] = - parseButDontEat(repMany1(a,b))~not(b)~>rep1(a)~repMany1(b,c)// ^^{case x~y => x:::y} - //val c : PackratParser[Any] = parseButDontEat(a)~a~a - //println(c((new PackratReader(new lexical.Scanner("45 24"))))) - val r = new PackratReader(new lexical.Scanner("45 b c")) - println(AnBnCn(r)) - println(r.getCache.size) -*/ -} diff --git a/test/files/run/packrat3.check b/test/files/run/packrat3.check deleted file mode 100644 index 8c106267..00000000 --- a/test/files/run/packrat3.check +++ /dev/null @@ -1,7 +0,0 @@ -(((List(a, b)~())~List(a))~List(b, c)) -(((List(a, a, b, b)~())~List(a, a))~List(b, b, c, c)) -(((List(a, a, a, b, b, b)~())~List(a, a, a))~List(b, b, b, c, c, c)) -(((List(a, a, a, a, b, b, b, b)~())~List(a, a, a, a))~List(b, b, b, b, c, c, c, c)) -Expected failure -``b'' expected but `c' found -end of input diff --git a/test/files/run/packrat3.scala b/test/files/run/packrat3.scala deleted file mode 100644 index 216ef8f0..00000000 --- a/test/files/run/packrat3.scala +++ /dev/null @@ -1,51 +0,0 @@ -import scala.util.parsing.combinator._ - -import scala.util.parsing.combinator.syntactical.StandardTokenParsers -import scala.util.parsing.input._ -import scala.util.parsing.combinator.token._ - -import scala.collection.mutable.HashMap - -object Test { - def main(args: Array[String]): Unit = { - import grammars3._ - - val head = phrase(AnBnCn) - - println(extractResult(head(new lexical.Scanner("a b c")))) - println(extractResult(head(new lexical.Scanner("a a b b c c")))) - println(extractResult(head(new lexical.Scanner("a a a b b b c c c")))) - println(extractResult(head(new lexical.Scanner("a a a a b b b b c c c c")))) - - println(extractResult(AnBnCn(new PackratReader(new lexical.Scanner("a a a b b b b c c c c"))))) - println(extractResult(AnBnCn(new PackratReader(new lexical.Scanner("a a a a b b b c c c c"))))) - println(extractResult(AnBnCn(new PackratReader(new lexical.Scanner("a a a a b b b b c c c"))))) - } -} - -object grammars3 extends StandardTokenParsers with PackratParsers { - - def extractResult(r: ParseResult[_]) = r match { - case Success(a,_) => a - case NoSuccess(a,_) => a - } - - - lexical.reserved ++= List("a","b", "c") - val a: PackratParser[Any] = memo("a") - val b: PackratParser[Any] = memo("b") - val c: PackratParser[Any] = memo("c") - - val AnBnCn: PackratParser[Any] = - guard(repMany1(a,b) ~ not(b)) ~ rep1(a) ~ repMany1(b,c)// ^^{case x~y => x:::y} - - - private def repMany[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = - ( p~repMany(p,q)~q ^^ {case x~xs~y => x::xs:::(y::Nil)} - | success(Nil) - ) - - def repMany1[T](p: => Parser[T], q: => Parser[T]): Parser[List[T]] = - p~opt(repMany(p,q))~q ^^ {case x~Some(xs)~y => x::xs:::(y::Nil)} - -} diff --git a/test/files/run/parserFilter.check b/test/files/run/parserFilter.check deleted file mode 100644 index be044544..00000000 --- a/test/files/run/parserFilter.check +++ /dev/null @@ -1,9 +0,0 @@ -[1.3] failure: Input doesn't match filter: false - -if false - ^ -[1.1] failure: Input doesn't match filter: not - -not true -^ -[1.8] parsed: (if~true) diff --git a/test/files/run/parserFilter.scala b/test/files/run/parserFilter.scala deleted file mode 100644 index d007d441..00000000 --- a/test/files/run/parserFilter.scala +++ /dev/null @@ -1,15 +0,0 @@ -object Test extends scala.util.parsing.combinator.RegexParsers { - val keywords = Set("if", "false") - def word: Parser[String] = "\\w+".r - - def keyword: Parser[String] = word filter (keywords.contains) - def ident: Parser[String] = word filter(!keywords.contains(_)) - - def test = keyword ~ ident - - def main(args: Array[String]) { - println(parseAll(test, "if false")) - println(parseAll(test, "not true")) - println(parseAll(test, "if true")) - } -} diff --git a/test/files/run/parserForFilter.check b/test/files/run/parserForFilter.check deleted file mode 100644 index a53c1477..00000000 --- a/test/files/run/parserForFilter.check +++ /dev/null @@ -1 +0,0 @@ -[1.13] parsed: (second,first) diff --git a/test/files/run/parserForFilter.scala b/test/files/run/parserForFilter.scala deleted file mode 100644 index 1bc44f80..00000000 --- a/test/files/run/parserForFilter.scala +++ /dev/null @@ -1,12 +0,0 @@ -object Test extends scala.util.parsing.combinator.RegexParsers { - def word: Parser[String] = "\\w+".r - - def twoWords = for { - (a ~ b) <- word ~ word - } yield (b, a) - - def main(args: Array[String]) { - println(parseAll(twoWords, "first second")) - } -} - diff --git a/test/files/run/parserJavaIdent.check b/test/files/run/parserJavaIdent.check deleted file mode 100644 index 597ddbee..00000000 --- a/test/files/run/parserJavaIdent.check +++ /dev/null @@ -1,26 +0,0 @@ -[1.7] parsed: simple -[1.8] parsed: with123 -[1.6] parsed: with$ -[1.10] parsed: withøßöèæ -[1.6] parsed: with_ -[1.6] parsed: _with -[1.1] failure: java identifier expected - -3start -^ -[1.1] failure: java identifier expected - --start -^ -[1.5] failure: java identifier expected - -with-s - ^ -[1.3] failure: java identifier expected - -we♥scala - ^ -[1.6] failure: java identifier expected - -with space - ^ diff --git a/test/files/run/parserJavaIdent.scala b/test/files/run/parserJavaIdent.scala deleted file mode 100644 index c068075e..00000000 --- a/test/files/run/parserJavaIdent.scala +++ /dev/null @@ -1,26 +0,0 @@ -object Test extends scala.util.parsing.combinator.JavaTokenParsers { - - def test[A](s: String) { - val res = parseAll(ident, s) match { - case Failure(_, in) => Failure("java identifier expected", in) - case o => o - } - println(res) - } - - def main(args: Array[String]) { - // Happy tests - test("simple") - test("with123") - test("with$") - test("withøßöèæ") - test("with_") - test("_with") - // Sad tests - test("3start") - test("-start") - test("with-s") - test("we♥scala") - test("with space") - } -} diff --git a/test/files/run/parserNoSuccessMessage.check b/test/files/run/parserNoSuccessMessage.check deleted file mode 100644 index fe00d2fd..00000000 --- a/test/files/run/parserNoSuccessMessage.check +++ /dev/null @@ -1,20 +0,0 @@ -[1.2] failure: string matching regex `\d+' expected but `x' found - --x - ^ -[1.1] failure: string matching regex `\d+' expected but `x' found - -x -^ -[1.3] parsed: (Some(-)~5) -[1.2] parsed: (None~5) -[1.2] error: Number expected! - --x - ^ -[1.1] error: Number expected! - -x -^ -[1.3] parsed: (Some(-)~5) -[1.2] parsed: (None~5) diff --git a/test/files/run/parserNoSuccessMessage.scala b/test/files/run/parserNoSuccessMessage.scala deleted file mode 100644 index 93aa252d..00000000 --- a/test/files/run/parserNoSuccessMessage.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test extends scala.util.parsing.combinator.RegexParsers { - def sign = "-" - def number = "\\d+".r - def p = sign.? ~ number withErrorMessage "Number expected!" - def q = sign.? ~! number withErrorMessage "Number expected!" - - def main(args: Array[String]) { - println(parseAll(p, "-x")) - println(parseAll(p, "x")) - println(parseAll(p, "-5")) - println(parseAll(p, "5")) - println(parseAll(q, "-x")) - println(parseAll(q, "x")) - println(parseAll(q, "-5")) - println(parseAll(q, "5")) - } -} - -