tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

space-string.js (941B)


      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  String space is used as gap.
      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(JSON.stringify(obj, null, ''), JSON.stringify(obj));
     28 assert.sameValue(JSON.stringify(obj, null, '  '), [
     29  '{'
     30 , '  "a1": {'
     31 , '    "b1": ['
     32 , '      1,'
     33 , '      2,'
     34 , '      3,'
     35 , '      4'
     36 , '    ],'
     37 , '    "b2": {'
     38 , '      "c1": 1,'
     39 , '      "c2": 2'
     40 , '    }'
     41 , '  },'
     42 , '  "a2": "a2"'
     43 , '}'
     44 ].join('\n'));
     45 
     46 reportCompare(0, 0);