Debian Codegraph @

js/src/tests/test262/built-ins/JSON/stringify/replacer-array-duplicates.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-json.stringify
5 description: >
6 Replacer array is deduped before Get.
7 info: |
8 JSON.stringify ( value [ , replacer [ , space ] ] )
9
10 [...]
11 4. If Type(replacer) is Object, then
12 [...]
13 4. Repeat, while k < len,
14 a. Let v be ? Get(replacer, ! ToString(k)).
15 [...]
16 f. If item is not undefined and item is not currently an element of PropertyList, then
17 i. Append item to the end of PropertyList.
18 ---*/
19
20 var getCalls = 0;
21 var value = {
22 get key() {
23 getCalls += 1;
24 return true;
25 },
26 };
27
28 assert.sameValue(JSON.stringify(value, ['key', 'key']), '{"key":true}');
29 assert.sameValue(getCalls, 1);
30
31 reportCompare(0, 0);