Debian Codegraph @

js/src/tests/test262/built-ins/JSON/stringify/space-string-range.js

raw
1 // Copyright (C) 2012 Ecma International. 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 Only first 10 code units of string space parameter are used.
7 info: |
8 JSON.stringify ( value [ , replacer [ , space ] ] )
9
10 [...]
11 7. Else if Type(space) is String, then
12 a. If the length of space is 10 or less, let gap be space; otherwise
13 let gap be the String value consisting of the first 10 code units of space.
14 ---*/
15
16 var obj = {
17 a1: {
18 b1: [1, 2, 3, 4],
19 b2: {
20 c1: 1,
21 c2: 2,
22 },
23 },
24 a2: 'a2',
25 };
26
27 assert.sameValue(
28 JSON.stringify(obj, null, '0123456789xxxxxxxxx'),
29 JSON.stringify(obj, null, '0123456789')
30 );
31
32 reportCompare(0, 0);