mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +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
Notes:
sideshowbarker
2024-07-17 16:19:57 +09:00
Author: https://github.com/IdanHo
Commit: 59080f441e
Pull-request: https://github.com/SerenityOS/serenity/pull/13438
Reviewed-by: https://github.com/linusg ✅
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