Debian Codegraph @

js/src/tests/test262/intl402/NumberFormat/style-unit.js

raw
1 // Copyright 2018 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-setnumberformatunitoptions
6 description: Checks handling of valid values for the numeric option to the RelativeTimeFormat constructor.
7 info: |
8 SetNumberFormatUnitOptions ( intlObj, options )
9
10 3. Let style be ? GetOption(options, "style", "string", « "decimal", "percent", "currency", "unit" », "decimal").
11 4. Set intlObj.[[Style]] to style.
12
13 features: [Intl.NumberFormat-unified]
14 ---*/
15
16 const validOptions = [
17 [undefined, "decimal"],
18 ["unit", "unit"],
19 [{ toString() { return "unit"; } }, "unit"],
20 ];
21
22 for (const [validOption, expected] of validOptions) {
23 const nf = new Intl.NumberFormat([], {"style": validOption, "unit": "gigabit"});
24 const resolvedOptions = nf.resolvedOptions();
25 assert.sameValue(resolvedOptions.style, expected);
26 }
27
28 reportCompare(0, 0);