tor-browser

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

value-primitive-top-level.js (1055B)


      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-serializejsonproperty
      5 description: >
      6  Top-level primitive values are stringified correctly.
      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  5. If value is null, return "null".
     17  6. If value is true, return "true".
     18  7. If value is false, return "false".
     19  8. If Type(value) is String, return QuoteJSONString(value).
     20  9. If Type(value) is Number, then
     21    a. If value is finite, return ! ToString(value).
     22  [...]
     23  11. Return undefined.
     24 ---*/
     25 
     26 assert.sameValue(JSON.stringify(null), 'null');
     27 assert.sameValue(JSON.stringify(true), 'true');
     28 assert.sameValue(JSON.stringify(false), 'false');
     29 assert.sameValue(JSON.stringify('str'), '"str"');
     30 assert.sameValue(JSON.stringify(123), '123');
     31 assert.sameValue(JSON.stringify(undefined), undefined);
     32 
     33 reportCompare(0, 0);