mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02:00
AK: Fix userland parsing of rounded floating point numbers
Parse JSON floating point literals properly, No longer throwing a SyntaxError when the decimal portion of the number exceeds the capacity of u32. Added tests to AK/TestJSON and LibJS/builtins/JSON/JSON.parse
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 18:43:35 +09:00
Author: https://github.com/ben-abraham Commit: https://github.com/SerenityOS/serenity/commit/23c72c6728 Pull-request: https://github.com/SerenityOS/serenity/pull/12429 Reviewed-by: https://github.com/trflynn89
@@ -43,3 +43,10 @@ test("negative zero", () => {
|
||||
|
||||
expect(JSON.parse(-0)).toEqual(0);
|
||||
});
|
||||
|
||||
// The underlying parser resolves decimal numbers by storing the decimal portion in an integer
|
||||
// This test handles a regression where the decimal portion was only using a u32 vs. u64
|
||||
// and would fail to parse.
|
||||
test("long decimal parse", () => {
|
||||
expect(JSON.parse("1644452550.6489999294281")).toEqual(1644452550.6489999294281);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user