diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/JSON/stringify/value-boolean-object.js')
-rw-r--r-- | js/src/tests/test262/built-ins/JSON/stringify/value-boolean-object.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/JSON/stringify/value-boolean-object.js b/js/src/tests/test262/built-ins/JSON/stringify/value-boolean-object.js new file mode 100644 index 0000000000..21fddf5eec --- /dev/null +++ b/js/src/tests/test262/built-ins/JSON/stringify/value-boolean-object.js @@ -0,0 +1,40 @@ +// Copyright (C) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-serializejsonproperty +description: > + Boolean objects are converted to primitives using [[BooleanData]]. +info: | + JSON.stringify ( value [ , replacer [ , space ] ] ) + + [...] + 12. Return ? SerializeJSONProperty(the empty String, wrapper). + + SerializeJSONProperty ( key, holder ) + + [...] + 4. If Type(value) is Object, then + [...] + c. Else if value has a [[BooleanData]] internal slot, then + i. Set value to value.[[BooleanData]]. + [...] + 6. If value is true, return "true". + 7. If value is false, return "false". +---*/ + +assert.sameValue(JSON.stringify(new Boolean(true)), 'true'); + +assert.sameValue( + JSON.stringify({ + toJSON: function() { + return {key: new Boolean(false)}; + }, + }), + '{"key":false}' +); + +assert.sameValue(JSON.stringify([1], function(_k, v) { + return v === 1 ? new Boolean(true) : v; +}), '[true]'); + +reportCompare(0, 0); |