test262/test/built-ins/JSON/stringify/bigint-replacer.js
Robin Templeton 184a37f011 additional BigInt JSON tests (#1235)
* additional BigInt JSON tests

* single quotes

* BigInt stringify order of steps
2017-10-03 17:00:31 -04:00

25 lines
690 B
JavaScript

// Copyright (C) 2017 Robin Templeton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: JSON serialization of BigInt values with replacer
esid: sec-serializejsonproperty
info: >
Runtime Semantics: SerializeJSONProperty ( key, holder )
3. If ReplacerFunction is not undefined, then
a. Set value to ? Call(ReplacerFunction, holder, « key, value »).
features: [BigInt]
---*/
function replacer(k, v)
{
if (typeof v === "bigint")
return "bigint";
else
return v;
}
assert.sameValue(JSON.stringify(0n, replacer), '"bigint"');
assert.sameValue(JSON.stringify({x: 0n}, replacer), '{"x":"bigint"}');