pointfreeco / swift-custom-dump

A collection of tools for debugging, diffing, and testing your application's data structures.
MIT License
800 stars 89 forks source link

Add XCTAssertNoDifference overload without Equatable requirement #75

Closed pyrtsa closed 1 year ago

pyrtsa commented 1 year ago

Sometimes we only need Equatable conformance for the purpose of unit tests. But with CustomDump.diff, we don't necessarily need Equatable conformance if we're willing to pay the performance hit of reflection and implicit opening of existentials during tests for a decreased application binary size.

The proposed XCTAssertNoDifference(lhs, rhs) overload in this PR allows asserting on non-Equatable values.

mbrandonw commented 1 year ago

Hey @pyrtsa, thanks for the PR! We actually had this at one point but decided against it because it is possible to get false positives. Since equality depends on the strength of the mirror it is possible for a type to omit some things from its mirror, causing tests to pass on values that are definitely not equal.

However, I could see us still shipping this tool but with a different name. Maybe XCTAssertLossyNoDifference or something.

mbrandonw commented 1 year ago

Hey @pyrtsa, after chatting with @stephencelis we decided to not accept this PR at this time. It should be possible to define this outside the library (let us know if not), and we think it's just got too many subtleties to be apart of the public API at this time.

I'm going to close for now, but feel free to open a discussion if you want to chat more about it!