aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch11/11.3/11.3.2_TRP.js
blob: 9409e258d14b100198444cfa0a3fe547ddbfa230 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2011-2012 Norbert Lindenberg. All rights reserved.
// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @description Tests that the digits are determined correctly when specifying significant digits.
 * @author Norbert Lindenberg
 */

$INCLUDE("testIntl.js");

var locales = [
    new Intl.NumberFormat().resolvedOptions().locale,
    "ar", "de", "th", "ja"
];
var numberingSystems = [
    "arab",
    "latn",
    "thai",
    "hanidec"
];
var testData = {
    "0": "0.00",
    "-0": "0.00",
    "123": "123",
    "-123": "-123",
    "12345": "12345",
    "-12345": "-12345",
    "123.45": "123.45",
    "-123.45": "-123.45",
    "123.44501": "123.45",
    "-123.44501": "-123.45",
    "0.001234": "0.001234",
    "-0.001234": "-0.001234",
    "0.00000000123": "0.00000000123",
    "-0.00000000123": "-0.00000000123",
    "0.00000000000000000000000000000123": "0.00000000000000000000000000000123",
    "-0.00000000000000000000000000000123": "-0.00000000000000000000000000000123",
    "1.2": "1.20",
    "-1.2": "-1.20",
    "0.0000000012344501": "0.0000000012345",
    "-0.0000000012344501": "-0.0000000012345",
    "123445.01": "123450",
    "-123445.01": "-123450",
    "12344501000000000000000000000000000": "12345000000000000000000000000000000",
    "-12344501000000000000000000000000000": "-12345000000000000000000000000000000"
};

testNumberFormat(locales, numberingSystems,
    {useGrouping: false, minimumSignificantDigits: 3, maximumSignificantDigits: 5},
    testData);