summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/NumberFormat/formatting-NaN.js
blob: 430d74222e33d97ce6f6f6060f2a0bf0715c7d34 (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
30
31
32
33
34
35
// |reftest| skip-if(!this.hasOwnProperty("Intl"))
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/

//-----------------------------------------------------------------------------
var BUGNUMBER = 1484943;
var summary = "Don't crash doing format/formatToParts on -NaN";

print(BUGNUMBER + ": " + summary);

//-----------------------------------------------------------------------------

assertEq("formatToParts" in Intl.NumberFormat(), true);

var nf = new Intl.NumberFormat("en-US");
var parts;

var values = [NaN, -NaN];

for (var v of values)
{
  assertEq(nf.format(v), "NaN");

  parts = nf.formatToParts(v);
  assertEq(parts.length, 1);
  assertEq(parts[0].type, "nan");
  assertEq(parts[0].value, "NaN");
}

//-----------------------------------------------------------------------------

if (typeof reportCompare === "function")
  reportCompare(0, 0, 'ok');

print("Tests complete");