Skip to content

Commit 1ed8220

Browse files
committed
Add tests for DurationFormat PR 172 and 167
Test the order of resolvedOptions in default setting Also add test to check the reading order of options based on the property returned in the default setting resolvedOptions. tc39/proposal-intl-duration-format#167 tc39/proposal-intl-duration-format#172 https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.resolvedOptions These two PRs are presenting to TC39 2023-09 meeting Swap actual/expected order Update test/intl402/DurationFormat/constructor-option-read-order.js Co-authored-by: André Bargull <andre.bargull@gmail.com> Fix per anba suggestion
1 parent d865ffe commit 1ed8220

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2023 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-Intl.DurationFormat
6+
description: Checks the order of option read.
7+
features: [Intl.DurationFormat]
8+
includes: [compareArray.js]
9+
---*/
10+
11+
let optionKeys = Object.keys((new Intl.DurationFormat()).resolvedOptions());
12+
let opt = {};
13+
let readKeys = new Array();
14+
// For each item returned by resolvedOptions of default, add a getter
15+
// to track the reading order.
16+
optionKeys.forEach((property) =>
17+
Object.defineProperty(opt, property, {
18+
get() {
19+
readKeys[readKeys.length] = property;
20+
return undefined;
21+
},
22+
}));
23+
let p = new Intl.DurationFormat(undefined, opt);
24+
assert.compareArray(
25+
readKeys,
26+
['numberingSystem',
27+
'style',
28+
'years',
29+
'yearsDisplay',
30+
'months',
31+
'monthsDisplay',
32+
'weeks',
33+
'weeksDisplay',
34+
'days',
35+
'daysDisplay',
36+
'hours',
37+
'hoursDisplay',
38+
'minutes',
39+
'minutesDisplay',
40+
'seconds',
41+
'secondsDisplay',
42+
'milliseconds',
43+
'millisecondsDisplay',
44+
'microseconds',
45+
'microsecondsDisplay',
46+
'nanoseconds',
47+
'nanosecondsDisplay']);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2023 the V8 project authors. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
/*---
4+
esid: sec-intl.durationformat.prototype.resolvedoptions
5+
description: order of property keys for the object returned by resolvedOptions()
6+
features: [Intl.DurationFormat]
7+
includes: [compareArray.js]
8+
---*/
9+
10+
assert.compareArray(
11+
Object.keys((new Intl.DurationFormat()).resolvedOptions()),
12+
['locale',
13+
'numberingSystem',
14+
'style',
15+
'years',
16+
'yearsDisplay',
17+
'months',
18+
'monthsDisplay',
19+
'weeks',
20+
'weeksDisplay',
21+
'days',
22+
'daysDisplay',
23+
'hours',
24+
'hoursDisplay',
25+
'minutes',
26+
'minutesDisplay',
27+
'seconds',
28+
'secondsDisplay',
29+
'milliseconds',
30+
'millisecondsDisplay',
31+
'microseconds',
32+
'microsecondsDisplay',
33+
'nanoseconds',
34+
'nanosecondsDisplay']);

0 commit comments

Comments
 (0)