Change expected results of hash-order-dependent tests

The spec already documents that these cases had undefined
behavior, so the tests were wrong and Java 8 broke them.
The tests are now still wrong, but have a comment that
should make it easier to understand what's happening next
time Java's hash table order changes.
This commit is contained in:
Havoc Pennington 2015-02-24 16:18:31 -05:00
parent 711fb504cb
commit 90ab6b6c12

View File

@ -924,20 +924,24 @@ class ConfigSubstitutionTest extends TestUtils {
@Test
def substSelfReferenceIndirect() {
// this has two possible outcomes depending on whether
// we resolve and memoize a first or b first. currently
// java 8's hash table makes it resolve OK, but
// it's also allowed to throw an exception.
val obj = parseObject("""a=1, b=${a}, a=${b}""")
val e = intercept[ConfigException.UnresolvedSubstitution] {
resolve(obj)
}
assertTrue("wrong exception: " + e.getMessage, e.getMessage.contains("cycle"))
val resolved = resolve(obj)
assertEquals(1, resolved.getInt("a"))
}
@Test
def substSelfReferenceDoubleIndirect() {
// this has two possible outcomes depending on whether we
// resolve and memoize a, b, or c first. currently java
// 8's hash table makes it resolve OK, but it's also
// allowed to throw an exception.
val obj = parseObject("""a=1, b=${c}, c=${a}, a=${b}""")
val e = intercept[ConfigException.UnresolvedSubstitution] {
resolve(obj)
}
assertTrue("wrong exception: " + e.getMessage, e.getMessage.contains("cycle"))
val resolved = resolve(obj)
assertEquals(1, resolved.getInt("a"))
}
@Test
@ -1002,7 +1006,7 @@ class ConfigSubstitutionTest extends TestUtils {
@Test
def substOptionalIndirectSelfReferenceInConcat() {
val obj = parseObject("""a=${?b}foo,b=${a}""")
val obj = parseObject("""a=${?b}foo,b=${?a}""")
val resolved = resolve(obj)
assertEquals("foo", resolved.getString("a"))
}