Debian Codegraph @

js/src/tests/test262/intl402/NumberFormat/constructor-trailingZeroDisplay.js

raw
1 // Copyright 2021 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-initializenumberformat
5 description: Checks handling of the trailingZeroDisplay option to the NumberFormat constructor.
6 includes: [compareArray.js]
7 features: [Intl.NumberFormat-v3]
8 ---*/
9
10 const values = [
11 [undefined, "auto"],
12 ["auto", "auto"],
13 ["stripIfInteger", "stripIfInteger"],
14 [{toString: function() { return "stripIfInteger"; }}, "stripIfInteger"],
15 ];
16
17 for (const [value, expected] of values) {
18 const callOrder = [];
19 const nf = new Intl.NumberFormat([], {
20 get roundingIncrement() {
21 callOrder.push("roundingIncrement");
22 return 1;
23 },
24 get trailingZeroDisplay() {
25 callOrder.push("trailingZeroDisplay");
26 return value;
27 }
28 });
29 const resolvedOptions = nf.resolvedOptions();
30 assert("trailingZeroDisplay" in resolvedOptions, "has property for value " + value);
31 assert.sameValue(resolvedOptions.trailingZeroDisplay, expected);
32
33 assert.compareArray(callOrder, ["roundingIncrement", "trailingZeroDisplay"]);
34 }
35
36 reportCompare(0, 0);