Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for PR "Read date-time options only once when creating DateTimeFormat objects" #3768

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializedatetimeformat
esid: sec-createdatetimeformat
description: Checks the order of getting options of 'dayPeriod' for the DateTimeFormat constructor.
info: |
ToDateTimeOptions ( options, required, defaults )
4. If required is "date" or "any", then
a. For each of the property names "weekday", "year", "month", "day", "dayPeriod" do
5. If required is "time" or "any", then
a. For each of the property names "hour", "minute", "second", do
CreateDateTimeFormat ( newTarget, locales, options, required, defaults )
...
36. For each row of Table 7, except the header row, in table order, do
a. Let prop be the name given in the Property column of the row.
b. If prop is "fractionalSecondDigits", then
i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined).
c. Else,
i. Let values be a List whose elements are the strings given in the Values column of the row.
ii. Let value be ? GetOption(options, prop, string, values, undefined).
d. Set formatOptions.[[<prop>]] to value.
...
includes: [compareArray.js]
features: [Intl.DateTimeFormat-dayPeriod]

---*/

// Just need to ensure dayPeriod are get between day and hour.
const expected = [
// ToDateTimeOptions step 4.
"day", "dayPeriod",
// ToDateTimeOptions step 5.
"hour",
// InitializeDateTimeFormat step 22.
// CreateDateTimeFormat step 36.
"day",
"dayPeriod",
"hour"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,37 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializedatetimeformat
esid: sec-createdatetimeformat
description: Checks the order of getting options of 'fractionalSecondDigits' for the DateTimeFormat constructor.
info: |
ToDateTimeOptions ( options, required, defaults )
5. If required is "time" or "any", then
a. For each of the property names "hour", "minute", "second", "fractionalSecondDigits", do

InitializeDateTimeFormat ( dateTimeFormat, locales, options )
2. Let options be ? ToDateTimeOptions(options, "any", "date").
CreateDateTimeFormat ( newTarget, locales, options, required, defaults )
...
4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
22. For each row of Table 5, except the header row, do
a. Let value be ? GetOption(options, prop, "string", « the strings given in the Values column of the row », undefined).
23. Let _opt_.[[FractionalSecondDigits]] be ? GetNumberOption(_options_, `"fractionalSecondDigits"`, 0, 3, 0).
26. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit").
...
36. For each row of Table 7, except the header row, in table order, do
a. Let prop be the name given in the Property column of the row.
b. If prop is "fractionalSecondDigits", then
i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined).
c. Else,
i. Let values be a List whose elements are the strings given in the Values column of the row.
ii. Let value be ? GetOption(options, prop, string, values, undefined).
d. Set formatOptions.[[<prop>]] to value.
37. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit").
...
includes: [compareArray.js]
features: [Intl.DateTimeFormat-fractionalSecondDigits]
---*/

// Just need to ensure fractionalSecondDigits are get
// between second and localeMatcher the first time and
// between timeZoneName and formatMatcher the second time.
// between "second" and "timeZoneName".
const expected = [
// InitializeDateTimeFormat step 2.
// ToDateTimeOptions step 5.
"second", "fractionalSecondDigits",
// InitializeDateTimeFormat step 4.
// CreateDateTimeFormat step 4.
"localeMatcher",
// InitializeDateTimeFormat step 22.
// CreateDateTimeFormat step 36.
"second",
"fractionalSecondDigits",
"timeZoneName",
// InitializeDateTimeFormat step 26.
// CreateDateTimeFormat step 37.
"formatMatcher",
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializedatetimeformat
esid: sec-createdatetimeformat
description: Checks the order of getting options for the DateTimeFormat constructor.
includes: [compareArray.js]
features: [Intl.DateTimeFormat-datetimestyle]
Expand All @@ -11,24 +11,15 @@ features: [Intl.DateTimeFormat-datetimestyle]
// To be merged into constructor-options-order.js when the feature is removed.

const expected = [
// ToDateTimeOptions step 4.
"weekday", "year", "month", "day",
// ToDateTimeOptions step 5.
"hour", "minute", "second",
// ToDateTimeOptions step 6.
"dateStyle",
// ToDateTimeOptions step 7.
"timeStyle",

// InitializeDateTimeFormat step 4.
// CreateDateTimeFormat step 4.
"localeMatcher",
// InitializeDateTimeFormat step 6.
// CreateDateTimeFormat step 12.
"hour12",
// InitializeDateTimeFormat step 7.
// CreateDateTimeFormat step 13.
"hourCycle",
// InitializeDateTimeFormat step 23.
// CreateDateTimeFormat step 29.
"timeZone",
// InitializeDateTimeFormat step 28.
// CreateDateTimeFormat step 36.
"weekday",
"era",
"year",
Expand All @@ -39,9 +30,9 @@ const expected = [
"second",
"timeZoneName",
"formatMatcher",
// InitializeDateTimeFormat step 32.
// CreateDateTimeFormat step 38.
"dateStyle",
// InitializeDateTimeFormat step 33.
// CreateDateTimeFormat step 40.
"timeStyle",
];

Expand Down
19 changes: 7 additions & 12 deletions test/intl402/DateTimeFormat/constructor-options-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializedatetimeformat
esid: sec-createdatetimeformat
description: Checks the order of getting options for the DateTimeFormat constructor.
includes: [compareArray.js]
---*/

const expected = [
// ToDateTimeOptions step 4.
"weekday", "year", "month", "day",
// ToDateTimeOptions step 5.
"hour", "minute", "second",

// InitializeDateTimeFormat step 4.
// CreateDateTimeFormat step 4.
"localeMatcher",
// InitializeDateTimeFormat step 6.
// CreateDateTimeFormat step 12.
"hour12",
// InitializeDateTimeFormat step 7.
// CreateDateTimeFormat step 13.
"hourCycle",
// InitializeDateTimeFormat step 17.
// CreateDateTimeFormat step 29.
"timeZone",
// InitializeDateTimeFormat step 22.
// CreateDateTimeFormat step 36.
"weekday",
"era",
"year",
Expand All @@ -31,7 +26,7 @@ const expected = [
"minute",
"second",
"timeZoneName",
// InitializeDateTimeFormat step 25.
// CreateDateTimeFormat step 37.
"formatMatcher",
];

Expand Down