Debian Codegraph @

js/src/tests/test262/intl402/DurationFormat/constructor-options-order.js

raw
1 // |reftest| skip-if(!Intl.hasOwnProperty('DurationFormat')) -- Intl.DurationFormat is not enabled unconditionally
2 // Copyright 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-Intl.DurationFormat
7 description: Checks the order of operations on the options argument to the DurationFormat constructor.
8 info: |
9 Intl.DurationFormat ( [ locales [ , options ] ] )
10 (...)
11 5. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
12 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
13 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long").
14 includes: [compareArray.js]
15 features: [Intl.DurationFormat]
16 ---*/
17
18 var actual = [];
19
20 const options = {
21 get localeMatcher() {
22 actual.push("localeMatcher");
23 return undefined;
24 },
25 get numberingSystem() {
26 actual.push("numberingSystem");
27 return undefined;
28 },
29 get style() {
30 actual.push("style");
31 return undefined;
32 },
33 };
34
35 const expected = [
36 "localeMatcher",
37 "numberingSystem",
38 "style"
39 ];
40
41 let nf = new Intl.DurationFormat(undefined, options);
42 assert.compareArray(actual, expected);
43
44 reportCompare(0, 0);