浏览代码

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
ForLoveOfCats 3 年之前
父节点
当前提交
71ab8fb757
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      Userland/Libraries/LibJS/Tests/builtins/JSON/JSON.parse.js

+ 8 - 0
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);
+});