Fix JSON.stringify (#2759)

There was a wrong check on the property types, it did not check that the
property was name accessor. Also fixed a test case.

JerryScript-DCO-1.0-Signed-off-by: Istvan Miklos imiklos2@inf.u-szeged.hu
This commit is contained in:
Istvan Miklos
2019-02-19 11:29:13 +01:00
committed by László Langó
parent 60bbd731e5
commit 9c10d82e4a
2 changed files with 2 additions and 3 deletions
@@ -1590,8 +1590,7 @@ ecma_builtin_json_object (ecma_object_t *obj_p, /**< the object*/
JERRY_ASSERT (ecma_is_property_enumerable (property));
if (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL)
if (ECMA_PROPERTY_GET_TYPE (property) != ECMA_PROPERTY_TYPE_SPECIAL)
{
ecma_append_to_values_collection (property_keys_p, *ecma_value_p, 0);
}
+1 -1
View File
@@ -146,7 +146,7 @@ function completeAssign (target, sources) {
}
var copy = completeAssign ({}, [obj]);
assert (JSON.stringify (copy) === '{"foo":1}');
assert (JSON.stringify (copy) === '{"foo":1,"bar":2}');
assert (copy.bar === 2);
// Test when target is not coercible to object