From 6052e19292c95270ac0a4bf30b6df47a257f88d4 Mon Sep 17 00:00:00 2001 From: James Roper Date: Fri, 5 Oct 2012 12:22:24 +1000 Subject: [backport] SI-6478 Fixing JavaTokenParser ident Backport of 256934160007079f473131469af2df4d023c2cfc from PR https://github.com/scala/scala/pull/1466 --- test/files/run/parserJavaIdent.check | 26 ++++++++++++++++++++++++++ test/files/run/parserJavaIdent.scala | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/files/run/parserJavaIdent.check create mode 100644 test/files/run/parserJavaIdent.scala (limited to 'test/files') diff --git a/test/files/run/parserJavaIdent.check b/test/files/run/parserJavaIdent.check new file mode 100644 index 0000000000..597ddbee47 --- /dev/null +++ b/test/files/run/parserJavaIdent.check @@ -0,0 +1,26 @@ +[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 new file mode 100644 index 0000000000..c068075e4e --- /dev/null +++ b/test/files/run/parserJavaIdent.scala @@ -0,0 +1,26 @@ +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") + } +} -- cgit v1.2.3