summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/NumberFormat/constructor-trailingZeroDisplay.js
blob: d474ef4aa3568425865b8a1cd585c5a1fea2daec (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
// Copyright 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-initializenumberformat
description: Checks handling of the trailingZeroDisplay option to the NumberFormat constructor.
includes: [compareArray.js]
features: [Intl.NumberFormat-v3]
---*/

const values = [
  [undefined, "auto"],
  ["auto", "auto"],
  ["stripIfInteger", "stripIfInteger"],
  [{toString: function() { return "stripIfInteger"; }}, "stripIfInteger"],
];

for (const [value, expected] of values) {
  const callOrder = [];
  const nf = new Intl.NumberFormat([], {
    get roundingIncrement() {
      callOrder.push("roundingIncrement");
      return 1;
    },
    get trailingZeroDisplay() {
      callOrder.push("trailingZeroDisplay");
      return value;
    }
  });
  const resolvedOptions = nf.resolvedOptions();
  assert("trailingZeroDisplay" in resolvedOptions, "has property for value " + value);
  assert.sameValue(resolvedOptions.trailingZeroDisplay, expected);

  assert.compareArray(callOrder, ["roundingIncrement", "trailingZeroDisplay"]);
}

reportCompare(0, 0);