tor-browser

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

value-number-negative-zero.js (779B)


      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  Negative zero numbers are stringified to "0".
      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  9. If Type(value) is Number, then
     17    a. If value is finite, return ! ToString(value).
     18 
     19  NumberToString ( m )
     20 
     21  [...]
     22  2. If m is +0 or -0, return the String "0".
     23 ---*/
     24 
     25 assert.sameValue(JSON.stringify(-0), '0');
     26 assert.sameValue(JSON.stringify(['-0', 0, -0]), '["-0",0,0]');
     27 assert.sameValue(JSON.stringify({key: -0}), '{"key":0}');
     28 
     29 reportCompare(0, 0);