Fix JSON.stringify empty array replacer handling (#3938)

In case of an empty array is used as a replacer for the JSON.stringify,
the output string should not contain any keys.

Fixes: #3926

JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
This commit is contained in:
Péter Gál authored and GitHub committed 2020-07-01 12:41:34 +02:00
1 parent 6389816f67
commit ca12a8f8f4
2 files changed
+25 -8

No files matched your search

+7
View File
@@ -212,3 +212,10 @@ assert (JSON.stringify (object, null, undefined) == '{"a":2}');
assert (JSON.stringify (object, null, new Boolean (true)) == '{"a":2}');
assert (JSON.stringify (object, null, [1, 2, 3] ) == '{"a":2}');
assert (JSON.stringify (object, null, { "a": 3 }) == '{"a":2}');
// Test array replacer
assert (JSON.stringify ({"key1": false, "key2": 12}, [], "abc") === '{}');
assert (JSON.stringify ({"key1": false, "key2": 12}, ["key1"], "abc") === '{\nabc"key1": false\n}');
assert (JSON.stringify ({"key1": false, "key2": 12}, ["key2"], "abc") === '{\nabc"key2": 12\n}');
assert (JSON.stringify ({"key1": false, "key2": 12}, ["key1", "key2"], "abc") === '{\nabc"key1": false,\nabc"key2": 12\n}');
assert (JSON.stringify ({"key1": false, "key2": 12}, ["key", "key3"], "abc") === '{}');