summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/NumberFormat/style-unit.js
blob: f41406dcfe55081af23993f64f5b4d1c0e01e516 (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
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-setnumberformatunitoptions
description: Checks handling of valid values for the numeric option to the RelativeTimeFormat constructor.
info: |
    SetNumberFormatUnitOptions ( intlObj, options )

    3. Let style be ? GetOption(options, "style", "string", « "decimal", "percent", "currency", "unit" », "decimal").
    4. Set intlObj.[[Style]] to style.

features: [Intl.NumberFormat-unified]
---*/

const validOptions = [
  [undefined, "decimal"],
  ["unit", "unit"],
  [{ toString() { return "unit"; } }, "unit"],
];

for (const [validOption, expected] of validOptions) {
  const nf = new Intl.NumberFormat([], {"style": validOption, "unit": "gigabit"});
  const resolvedOptions = nf.resolvedOptions();
  assert.sameValue(resolvedOptions.style, expected);
}

reportCompare(0, 0);