diff options
author | serenitydev <ben.d.abraham@gmail.com> | 2022-02-11 03:29:08 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2022-02-16 07:22:51 -0500 |
commit | 23c72c67285743c9815f7ea82bd35b94aa179893 (patch) | |
tree | 11ebcf2ee9842d6692e61df18f003a2f0e85a63d /Userland | |
parent | af75503c173b974b368307bb3fdc974b620d76d1 (diff) | |
download | serenity-23c72c67285743c9815f7ea82bd35b94aa179893.zip |
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
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js b/Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js index 6cc501f51a..a05e579e2a 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js +++ b/Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js @@ -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); +}); |