Debian Codegraph @

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

raw
1 // Copyright 2019 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-initializenumberformat
6 description: Checks handling of the compactDisplay option to the NumberFormat constructor.
7 info: |
8 InitializeNumberFormat ( numberFormat, locales, options )
9
10 23. Let signDisplay be ? GetOption(options, "signDisplay", "string", « "auto", "never", "always", "exceptZero" », "auto").
11 24. Set numberFormat.[[SignDisplay]] to signDisplay.
12
13 features: [Intl.NumberFormat-unified]
14 ---*/
15
16 const values = [
17 [undefined, "auto"],
18 ["auto"],
19 ["never"],
20 ["always"],
21 ["exceptZero"],
22 ];
23
24 for (const [value, expected = value] of values) {
25 const nf = new Intl.NumberFormat([], {
26 signDisplay: value,
27 });
28 const resolvedOptions = nf.resolvedOptions();
29 assert.sameValue("signDisplay" in resolvedOptions, true);
30 assert.sameValue(resolvedOptions.signDisplay, expected);
31 }
32
33 reportCompare(0, 0);