PolymerLabs / arcs

Arcs
BSD 3-Clause "New" or "Revised" License
56 stars 35 forks source link

Add a tolerance to ReferencablePrimitive.equals for floats and doubles. #7034

Closed copybara-service[bot] closed 3 years ago

copybara-service[bot] commented 3 years ago

Add a tolerance to ReferencablePrimitive.equals for floats and doubles.

Round-tripping values through serialization can change the values of floating point numbers ever so slightly, affecting equality comparisons, e.g.:

expected : Primitive(0.695700200506916) but was : Primitive(0.6957002005069159)

Also fixed a small bug where ReferenceablePrimitive.equals() would consider other Referencable subclasses to be equal, so long as their ids matched (there were a couple of tests I had to fix up which were unintentionally exploiting this bug)