mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibJS: Normalize NaN values in Sets and Maps
This ensures that different NaN types (e.g. 0/0, 0 * Infinity, etc) are mapped to the same Set/Map entry.
This commit is contained in:
parent
cc08f82ddb
commit
59080f441e
3 changed files with 26 additions and 0 deletions
|
@ -9,3 +9,12 @@ test("basic functionality", () => {
|
|||
expect(map.get("a")).toBe(0);
|
||||
expect(map.get("d")).toBe(undefined);
|
||||
});
|
||||
|
||||
test("NaN differentiation", () => {
|
||||
const map = new Map();
|
||||
map.set(NaN, "a");
|
||||
|
||||
expect(map.get(0 / 0)).toBe("a");
|
||||
expect(map.get(0 * Infinity)).toBe("a");
|
||||
expect(map.get(Infinity - Infinity)).toBe("a");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue