test262/test/built-ins/JSON/stringify/bigint-replacer.js
André Bargull f95b56ab28 Revert "js-beautify: make all indentation consistent (depth & character) (#1409)" (#1412)
This reverts commit a01de4a722d088055a7d84d8c691ddd7109edb34.
2018-02-09 12:09:47 -05: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"}');