Skip to content

Commit

Permalink
Update firstDay test to latest spec after PR 79
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang authored and ptomato committed Jul 10, 2024
1 parent 318df8f commit 929e932
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ info: |
Intl.Locale( tag [, options] )
...
x. Let numberingSystem be ? GetOption(options, "firstDayOfWeek", "string", < *"mon"*, *"tue"*, *"wed"*, *"thu"*, *"fri"*, *"sat"*, *"sun"*, *"0"*, *"1"*, *"2"*, *"3"*, *"4"*, *"5"*, *"6"*, *"7"*> , undefined).
x. Let fw be ? GetOption(options, "firstDayOfWeek", "string", undefined, undefined).
x. If fw is not undefined, then
x. Set fw to !WeekdayToString(fw).
x. If fw does not match the type sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a RangeError exception.
...
features: [Intl.Locale,Intl.Locale-info]
Expand All @@ -19,10 +22,7 @@ const invalidFirstDayOfWeekOptions = [
"",
"m",
"mo",
"monday",
true,
false,
null,
"longerThan8Chars",
];
for (const firstDayOfWeek of invalidFirstDayOfWeekOptions) {
assert.throws(RangeError, function() {
Expand Down
33 changes: 24 additions & 9 deletions test/intl402/Locale/constructor-options-firstDayOfWeek-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ info: |
Intl.Locale( tag [, options] )
...
x. Let numberingSystem be ? GetOption(options, "firstDayOfWeek", "string", < *"mon"*, *"tue"*, *"wed"*, *"thu"*, *"fri"*, *"sat"*, *"sun"*, *"0"*, *"1"*, *"2"*, *"3"*, *"4"*, *"5"*, *"6"*, *"7"*> , undefined).
x. Let firstDay be *undefined*.
x. If fw is not *undefined*, then
x. Set firstDay to !WeekdayToString(fw).
x. Set opt.[[fw]] to firstDay.
x. Let fw be ? GetOption(options, "firstDayOfWeek", "string", undefined, undefined).
x. If fw is not undefined, then
x. Set fw to !WeekdayToString(fw).
x. If fw does not match the type sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a RangeError exception.
x. Set opt.[[fw]] to fw.
...
x. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
...
x. Let firstDay be *undefined*.
x. If r.[[fw]] is not *undefined*, then
x. Set firstDay to ! WeekdayToNumber(r.[[fw]]).
x. Set locale.[[FirstDayOfWeek]] to firstDay.
x. Set locale.[[FirstDayOfWeek]] to r.[[fw]].
...
features: [Intl.Locale,Intl.Locale-info]
Expand Down Expand Up @@ -50,6 +47,24 @@ const validFirstDayOfWeekOptions = [
[6, "en-u-fw-sat"],
[7, "en-u-fw-sun"],
[0, "en-u-fw-sun"],
[true, "en-u-fw-true"],
[false, "en-u-fw-false"],
[null, "en-u-fw-null"],
["primidi", "en-u-fw-primidi"],
["duodi", "en-u-fw-duodi"],
["tridi", "en-u-fw-tridi"],
["quartidi", "en-u-fw-quartidi"],
["quintidi", "en-u-fw-quintidi"],
["sextidi", "en-u-fw-sextidi"],
["septidi", "en-u-fw-septidi"],
["octidi", "en-u-fw-octidi"],
["nonidi", "en-u-fw-nonidi"],
["decadi", "en-u-fw-decadi"],
["frank", "en-u-fw-frank"],
["yungfong", "en-u-fw-yungfong"],
["yung-fong", "en-u-fw-yung-fong"],
["tang", "en-u-fw-tang"],
["frank-yung-fong-tang", "en-u-fw-frank-yung-fong-tang"],
];
for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
assert.sameValue(
Expand Down
14 changes: 7 additions & 7 deletions test/intl402/Locale/prototype/firstDayOfWeek/valid-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ features: [Intl.Locale,Intl.Locale-info]
---*/

const validIds = [
["en-u-fw-mon", 1],
["en-u-fw-tue", 2],
["en-u-fw-wed", 3],
["en-u-fw-thu", 4],
["en-u-fw-fri", 5],
["en-u-fw-sat", 6],
["en-u-fw-sun", 7],
["en-u-fw-mon", "mon"],
["en-u-fw-tue", "tue"],
["en-u-fw-wed", "wed"],
["en-u-fw-thu", "thu"],
["en-u-fw-fri", "fri"],
["en-u-fw-sat", "sat"],
["en-u-fw-sun", "sun"],
];
for (const [id, expected] of validIds) {
assert.sameValue(
Expand Down
46 changes: 23 additions & 23 deletions test/intl402/Locale/prototype/firstDayOfWeek/valid-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ features: [Intl.Locale,Intl.Locale-info]
---*/

const validFirstDayOfWeekOptions = [
["mon", 1],
["tue", 2],
["wed", 3],
["thu", 4],
["fri", 5],
["sat", 6],
["sun", 7],
["1", 1],
["2", 2],
["3", 3],
["4", 4],
["5", 5],
["6", 6],
["7", 7],
["0", 7],
[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5],
[6, 6],
[7, 7],
[0, 7],
["mon", "mon"],
["tue", "tue"],
["wed", "wed"],
["thu", "thu"],
["fri", "fri"],
["sat", "sat"],
["sun", "sun"],
["1", "mon"],
["2", "tue"],
["3", "wed"],
["4", "thu"],
["5", "fri"],
["6", "sat"],
["7", "sun"],
["0", "sun"],
[1, "mon"],
[2, "tue"],
[3, "wed"],
[4, "thu"],
[5, "fri"],
[6, "sat"],
[7, "sun"],
[0, "sun"],
];
for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
assert.sameValue(
Expand Down

0 comments on commit 929e932

Please sign in to comment.