Debian Codegraph @

js/src/tests/test262/intl402/DurationFormat/constructor-option-read-order.js

raw
1 // |reftest| skip-if(!Intl.hasOwnProperty('DurationFormat')) -- Intl.DurationFormat is not enabled unconditionally
2 // Copyright 2023 the V8 project authors. 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 option read.
8 features: [Intl.DurationFormat]
9 includes: [compareArray.js]
10 ---*/
11
12 let optionKeys = Object.keys((new Intl.DurationFormat()).resolvedOptions());
13 let opt = {};
14 let readKeys = new Array();
15 // For each item returned by resolvedOptions of default, add a getter
16 // to track the reading order.
17 optionKeys.forEach((property) =>
18 Object.defineProperty(opt, property, {
19 get() {
20 readKeys[readKeys.length] = property;
21 return undefined;
22 },
23 }));
24 let p = new Intl.DurationFormat(undefined, opt);
25 assert.compareArray(
26 readKeys,
27 ['numberingSystem',
28 'style',
29 'years',
30 'yearsDisplay',
31 'months',
32 'monthsDisplay',
33 'weeks',
34 'weeksDisplay',
35 'days',
36 'daysDisplay',
37 'hours',
38 'hoursDisplay',
39 'minutes',
40 'minutesDisplay',
41 'seconds',
42 'secondsDisplay',
43 'milliseconds',
44 'millisecondsDisplay',
45 'microseconds',
46 'microsecondsDisplay',
47 'nanoseconds',
48 'nanosecondsDisplay']);
49
50 reportCompare(0, 0);