I would appreciate someone explaining to me why the following is true:
def t = "test"
assert [test: 1] == ["test": 1] // 1. expected
assert ["$t": 1] != ["test": 1] // 2. unexpected
assert ["$t": 1] != [test: 1] // 3. unexpected
assert ["$t": 1] == ["$t": 1] // 4. expected
println ["$t": 1] // output: [test: 1]
println ["test": 1] // output: [test: 1]
I don't understand why there is the inequality for results #2 and #3.
I ran into this in writing a test where the key get dynamically created in the code, but given the test conditions I know it should be the string "test". The problem is that the returned "appears" correct but is not considered equal. And I don't understand why.
Further, the following "works":
def t = "test"
def odd = ["$t": 1]
assert !odd["$t"]
assert !odd.test
assert !odd["test"]
assert !odd."$t"
println odd // output: [test: 1]
def d = new Date()
def t2 = "$t"
def odd2 = [(t2): 1, (d): 2]
assert odd2[d] == 2
assert !odd2[d.toString()]
assert !odd2[t2] // expected 1
odd2.put(t2, 3)
println odd2 // output: [test: 3, /* date#toString */: 2]
assert odd.getAt(d) == 2
assert !odd2.getAt(t2) // expected 3