Debian Codegraph @

js/src/tests/test262/built-ins/JSON/stringify/value-tojson-abrupt.js

raw
1 // Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-serializejsonproperty
5 description: >
6 Abrupt completions from Get and Call.
7 info: |
8 JSON.stringify ( value [ , replacer [ , space ] ] )
9
10 [...]
11 12. Return ? SerializeJSONProperty(the empty String, wrapper).
12
13 SerializeJSONProperty ( key, holder )
14
15 [...]
16 2. If Type(value) is Object, then
17 a. Let toJSON be ? Get(value, "toJSON").
18 b. If IsCallable(toJSON) is true, then
19 i. Set value to ? Call(toJSON, value, « key »).
20 ---*/
21
22 assert.throws(Test262Error, function() {
23 JSON.stringify({
24 get toJSON() {
25 throw new Test262Error();
26 },
27 });
28 });
29
30 assert.throws(Test262Error, function() {
31 JSON.stringify({
32 toJSON() {
33 throw new Test262Error();
34 },
35 });
36 });
37
38 reportCompare(0, 0);