|
1 // Copyright 2013 Mozilla Corporation. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * @description Tests that the options minimumSignificantDigits and |
|
6 * maximumSignificantDigits are read in the right sequence. |
|
7 * @author Norbert Lindenberg |
|
8 */ |
|
9 |
|
10 var read = 0; |
|
11 |
|
12 function readMinimumSignificantDigits() { |
|
13 ++read; |
|
14 if (read === 1) { |
|
15 return 0; // invalid value, but on first read that's OK |
|
16 } else if (read === 3) { |
|
17 return 1; // valid value |
|
18 } else { |
|
19 $ERROR("minimumSignificantDigits read out of sequence: " + read + "."); |
|
20 } |
|
21 } |
|
22 |
|
23 function readMaximumSignificantDigits() { |
|
24 ++read; |
|
25 if (read === 2) { |
|
26 return 0; // invalid value, but on first read that's OK |
|
27 } else if (read === 4) { |
|
28 return 1; // valid value |
|
29 } else { |
|
30 $ERROR("maximumSignificantDigits read out of sequence: " + read + "."); |
|
31 } |
|
32 } |
|
33 |
|
34 var options = {}; |
|
35 Object.defineProperty(options, "minimumSignificantDigits", |
|
36 { get: readMinimumSignificantDigits }); |
|
37 Object.defineProperty(options, "maximumSignificantDigits", |
|
38 { get: readMaximumSignificantDigits }); |
|
39 |
|
40 new Intl.NumberFormat("de", options); |
|
41 |
|
42 if (read !== 4) { |
|
43 $ERROR("insuffient number of property reads: " + read + "."); |
|
44 } |