summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/JSON/stringify/value-number-negative-zero.js
blob: 665340762e062e0064cfc04b2b16370b07caf1ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-serializejsonproperty
description: >
  Negative zero numbers are stringified to "0".
info: |
  JSON.stringify ( value [ , replacer [ , space ] ] )

  [...]
  12. Return ? SerializeJSONProperty(the empty String, wrapper).

  SerializeJSONProperty ( key, holder )

  [...]
  9. If Type(value) is Number, then
    a. If value is finite, return ! ToString(value).

  NumberToString ( m )

  [...]
  2. If m is +0 or -0, return the String "0".
---*/

assert.sameValue(JSON.stringify(-0), '0');
assert.sameValue(JSON.stringify(['-0', 0, -0]), '["-0",0,0]');
assert.sameValue(JSON.stringify({key: -0}), '{"key":0}');

reportCompare(0, 0);