Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/JSON/stringify/bigint-tojson.js

raw
1 // Copyright (C) 2017 Robin Templeton. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: BigInt toJSON method
6 esid: sec-serializejsonproperty
7 info: |
8 Runtime Semantics: SerializeJSONProperty ( key, holder )
9
10 2. If Type(value) is Object or BigInt, then
11 a. Let toJSON be ? GetGetV(value, "toJSON").
12 b. If IsCallable(toJSON) is true, then
13 i. Set value to ? Call(toJSON, value, « key »).
14 features: [BigInt]
15 ---*/
16
17 BigInt.prototype.toJSON = function () { return this.toString(); };
18 assert.sameValue(JSON.stringify(0n), '"0"');