Debian Codegraph @

js/src/tests/test262/intl402/NumberFormat/currencyDisplay-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 NumberFormat constructor.
7 info: |
8 SetNumberFormatUnitOptions ( intlObj, options )
9
10 6. Let currencyDisplay be ? GetOption(options, "currencyDisplay", "string", « "code", "symbol", "narrowSymbol", "name" », "symbol").
11 11. If style is "currency", then
12 f. Set intlObj.[[CurrencyDisplay]] to currencyDisplay.
13
14 features: [Intl.NumberFormat-unified]
15 ---*/
16
17 const validOptions = [
18 [undefined, "symbol"],
19 ["narrowSymbol", "narrowSymbol"],
20 [{ toString() { return "narrowSymbol"; } }, "narrowSymbol"],
21 ];
22
23 for (const [validOption, expected] of validOptions) {
24 const nf = new Intl.NumberFormat([], {
25 "style": "currency",
26 "currency": "EUR",
27 "currencyDisplay": validOption,
28 });
29 const resolvedOptions = nf.resolvedOptions();
30 assert.sameValue(resolvedOptions.currencyDisplay, expected);
31 }
32
33 for (const [validOption] of validOptions) {
34 const nf = new Intl.NumberFormat([], {
35 "style": "percent",
36 "currencyDisplay": validOption,
37 });
38 const resolvedOptions = nf.resolvedOptions();
39 assert.sameValue(resolvedOptions.currencyDisplay, undefined);
40 }
41
42 reportCompare(0, 0);