Skip to content

Commit d7a78ef

Browse files
committed
tests: add test for comparing decimals floats
1 parent 7a072e0 commit d7a78ef

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

polyfill/composite.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,21 @@ await test(".equal deep", () => {
124124
"Deeply nested composites c5 and c7 should not be equal due to differing additional properties",
125125
);
126126
});
127+
await test(".equal composites decimal numbers", () => {
128+
const c1 = Composite({ a: 2.0 });
129+
const c2 = Composite({ a: 2.5 });
130+
assert(c1 !== c2, "c1 and c2 should not be the same object");
131+
assert(!Composite.equal(c1, c2), "c1 and c2 should not be equal");
132+
const c3 = Composite({ a: 2.5 });
133+
assert(c2 !== c3, "c2 and c3 should not be the same object");
134+
assert(Composite.equal(c2, c3), "c2 and c3 should be equal");
135+
});
136+
await test(".equal composites interesting decimal numbers", () => {
137+
const c1 = Composite({ a: 1 + Number.EPSILON });
138+
const c2 = Composite({ a: 1 + 2 * Number.EPSILON });
139+
assert(c1 !== c2, "c1 and c2 should not be the same object");
140+
assert(!Composite.equal(c1, c2), "c1 and c2 should not be equal");
141+
const c3 = Composite({ a: 1 + 2 * Number.EPSILON });
142+
assert(c2 !== c3, "c2 and c3 should not be the same object");
143+
assert(Composite.equal(c2, c3), "c2 and c3 should be equal");
144+
});

0 commit comments

Comments
 (0)