From e1329e54bf10fb84066653cbf67a9fc24427e143 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 16 Nov 2011 21:25:29 -0500 Subject: [PATCH] test the current behavior of duplicate keys set to object, then primitive, then object --- .../typesafe/config/impl/ConfParserTest.scala | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala b/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala index a4dac2bc..91fe67be 100644 --- a/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala +++ b/src/test/scala/com/typesafe/config/impl/ConfParserTest.scala @@ -188,6 +188,23 @@ class ConfParserTest extends TestUtils { assertEquals(100, obj.getInt("a.b.c.z")) } + @Test + def duplicateKeyObjectNullObject() { + // null is supposed to "reset" the object at key "a" + val obj = parseObject("""{ a : { b : 1 }, a : null, a : { c : 2 } }""") + assertEquals(1, obj.size()) + assertEquals(1, obj.getObject("a").size()) + assertEquals(2, obj.getInt("a.c")) + } + + @Test + def duplicateKeyObjectNumberObject() { + val obj = parseObject("""{ a : { b : 1 }, a : 42, a : { c : 2 } }""") + assertEquals(1, obj.size()) + assertEquals(1, obj.getObject("a").size()) + assertEquals(2, obj.getInt("a.c")) + } + @Test def impliedCommaHandling() { val valids = Seq(