summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/JSON/stringify/value-bigint-replacer.js
blob: e7048872e5210debe5854a586aa05804578ed122 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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"}');

reportCompare(0, 0);