Describe the bug
When working with two heterogeneous dictionaries of type [AnyHashable, AnyHasable] in order to compare them where one dictionary represents a floating point value using a Float type and the other using Double leads to a very subtle error where the diff presented shows the two comparing fields as different yet show a identical literal representation.
To Reproduce
func testBug() {
let values: [AnyHashable: AnyHashable] = [
"value": Float(29.99)
]
let expected: [AnyHashable: AnyHashable] = [
"value": 29.99, // Is a Double
]
XCTAssertNoDifference(values, expected)
}
Expected behavior
I assume due to precision that Float vs Double can't be compared like for like but I would expected XCTAssertNoDifference to maybe show the type information where the two values are literal identical and where the types are different, so something like:
I spent hours trying to work out why my two hashable dictionaries that appeared to have identical values were failing and the diff output was confusing things further. It was very subtle that the code under test was using a Float value and my dictionary I wanted to compare against used a Double literal.
Describe the bug When working with two heterogeneous dictionaries of type
[AnyHashable, AnyHasable]
in order to compare them where one dictionary represents a floating point value using aFloat
type and the other usingDouble
leads to a very subtle error where the diff presented shows the two comparing fields as different yet show a identical literal representation.To Reproduce
Expected behavior I assume due to precision that Float vs Double can't be compared like for like but I would expected
XCTAssertNoDifference
to maybe show the type information where the two values are literal identical and where the types are different, so something like:I spent hours trying to work out why my two hashable dictionaries that appeared to have identical values were failing and the diff output was confusing things further. It was very subtle that the code under test was using a
Float
value and my dictionary I wanted to compare against used a Double literal.Screenshots
Environment