aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite/intl402/ch11/11.1/11.1.1_32.js
blob: 9196318efbf2210b8140ecb5c65882bc181f30c6 (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
// Copyright 2013 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @description Tests that the options minimumSignificantDigits and
 *     maximumSignificantDigits are read in the right sequence.
 * @author Norbert Lindenberg
 */

var read = 0;

function readMinimumSignificantDigits() {
    ++read;
    if (read === 1) {
        return 0; // invalid value, but on first read that's OK
    } else if (read === 3) {
        return 1; // valid value
    } else {
        $ERROR("minimumSignificantDigits read out of sequence: " + read + ".");
    }
}

function readMaximumSignificantDigits() {
    ++read;
    if (read === 2) {
        return 0; // invalid value, but on first read that's OK
    } else if (read === 4) {
        return 1; // valid value
    } else {
        $ERROR("maximumSignificantDigits read out of sequence: " + read + ".");
    }
}

var options = {};
Object.defineProperty(options, "minimumSignificantDigits",
    { get: readMinimumSignificantDigits });
Object.defineProperty(options, "maximumSignificantDigits",
    { get: readMaximumSignificantDigits });

new Intl.NumberFormat("de", options);

if (read !== 4) {
    $ERROR("insuffient number of property reads: " + read + ".");
}