summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForLoveOfCats <floc@unpromptedtirade.com>2022-01-19 11:42:25 -0500
committerLinus Groh <mail@linusgroh.de>2022-01-19 21:51:09 +0000
commit71ab8fb757f560d50f1c324fbdfa5678597d0b69 (patch)
treeb3a7667cdf642b937894ebdc0534d80e1fd36271
parent1d95fd54433c0f561f6efaac007b12a9fcd22a0b (diff)
downloadserenity-71ab8fb757f560d50f1c324fbdfa5678597d0b69.zip
LibJS: Add in-tree test for Json parsing of negative zeros
This mirrors the cases in `built-ins/JSON/parse/text-negative-zero` in test262
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js8
1 files changed, 8 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 7f82392666..6cc501f51a 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js
@@ -35,3 +35,11 @@ test("syntax errors", () => {
}).toThrow(SyntaxError);
});
});
+
+test("negative zero", () => {
+ ["-0", " \n-0", "-0 \t", "\n\t -0\n ", "-0.0"].forEach(testCase => {
+ expect(JSON.parse(testCase)).toEqual(-0.0);
+ });
+
+ expect(JSON.parse(-0)).toEqual(0);
+});