From a722d5249e4c3ef312f434d326d8501ce11053af Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 10 Nov 2011 20:52:06 -0500 Subject: [PATCH] add some tests for paths with hyphen and underscore in them --- src/test/resources/test02.conf | 5 ++++- .../com/typesafe/config/impl/ConfParserTest.scala | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/resources/test02.conf b/src/test/resources/test02.conf index b64c9bd7..c98d316f 100644 --- a/src/test/resources/test02.conf +++ b/src/test/resources/test02.conf @@ -7,5 +7,8 @@ "57_a" : ${a.b.c}, "57_b" : ${"a"."b"."c"}, "a.b.c" : 103, - "103_a" : ${"a.b.c"} + "103_a" : ${"a.b.c"}, + "a-c" : 259, + "a_c" : 260, + "-" : 261 } diff --git a/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala b/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala index 9a76ab60..f45884cd 100644 --- a/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala +++ b/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala @@ -65,7 +65,7 @@ class ConfParserTest extends TestUtils { } // also parse with the standalone path parser and be sure the - // outcome is the same + // outcome is the same. val shouldBeSame = Parser.parsePath(s) assertEquals(result, shouldBeSame) @@ -95,6 +95,9 @@ class ConfParserTest extends TestUtils { assertEquals(path("a", ""), parsePath("a.\"\"\"\"")) assertEquals(path("", "b"), parsePath("\"\"\"\".b")) assertEquals(path("", "", ""), parsePath(""" "".""."" """)) + assertEquals(path("a-c"), parsePath("a-c")) + assertEquals(path("a_c"), parsePath("a_c")) + assertEquals(path("-"), parsePath("\"-\"")) for (invalid <- Seq("a.", ".b", "a..b", "a${b}c", "\"\".", ".\"\"")) { try { @@ -107,5 +110,10 @@ class ConfParserTest extends TestUtils { throw e; } } + + intercept[ConfigException.Parse] { + // this gets parsed as a number since it starts with '-' + parsePath("-") + } } }