Update firstDay test to latest spec after PR 79

Spec Changes merged
https://github.com/tc39/proposal-intl-locale-info/pull/79
This commit is contained in:
Frank Tang 2024-07-09 13:51:47 -07:00 committed by Philip Chimento
parent 318df8f01e
commit 7b154389ce
4 changed files with 59 additions and 44 deletions

View File

@ -9,7 +9,10 @@ info: |
Intl.Locale( tag [, options] ) 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] features: [Intl.Locale,Intl.Locale-info]
@ -19,10 +22,7 @@ const invalidFirstDayOfWeekOptions = [
"", "",
"m", "m",
"mo", "mo",
"monday", "longerThan8Chars",
true,
false,
null,
]; ];
for (const firstDayOfWeek of invalidFirstDayOfWeekOptions) { for (const firstDayOfWeek of invalidFirstDayOfWeekOptions) {
assert.throws(RangeError, function() { assert.throws(RangeError, function() {

View File

@ -9,18 +9,15 @@ info: |
Intl.Locale( tag [, options] ) 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. Let firstDay be *undefined*. x. If fw is not undefined, then
x. If fw is not *undefined*, then x. Set fw to !WeekdayToString(fw).
x. Set firstDay 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 firstDay. x. Set opt.[[fw]] to fw.
... ...
x. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys). x. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
... ...
x. Let firstDay be *undefined*. x. Set locale.[[FirstDayOfWeek]] to r.[[fw]].
x. If r.[[fw]] is not *undefined*, then
x. Set firstDay to ! WeekdayToNumber(r.[[fw]]).
x. Set locale.[[FirstDayOfWeek]] to firstDay.
... ...
features: [Intl.Locale,Intl.Locale-info] features: [Intl.Locale,Intl.Locale-info]
@ -50,6 +47,24 @@ const validFirstDayOfWeekOptions = [
[6, "en-u-fw-sat"], [6, "en-u-fw-sat"],
[7, "en-u-fw-sun"], [7, "en-u-fw-sun"],
[0, "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) { for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
assert.sameValue( assert.sameValue(

View File

@ -13,13 +13,13 @@ features: [Intl.Locale,Intl.Locale-info]
---*/ ---*/
const validIds = [ const validIds = [
["en-u-fw-mon", 1], ["en-u-fw-mon", "mon"],
["en-u-fw-tue", 2], ["en-u-fw-tue", "tue"],
["en-u-fw-wed", 3], ["en-u-fw-wed", "wed"],
["en-u-fw-thu", 4], ["en-u-fw-thu", "thu"],
["en-u-fw-fri", 5], ["en-u-fw-fri", "fri"],
["en-u-fw-sat", 6], ["en-u-fw-sat", "sat"],
["en-u-fw-sun", 7], ["en-u-fw-sun", "sun"],
]; ];
for (const [id, expected] of validIds) { for (const [id, expected] of validIds) {
assert.sameValue( assert.sameValue(

View File

@ -13,29 +13,29 @@ features: [Intl.Locale,Intl.Locale-info]
---*/ ---*/
const validFirstDayOfWeekOptions = [ const validFirstDayOfWeekOptions = [
["mon", 1], ["mon", "mon"],
["tue", 2], ["tue", "tue"],
["wed", 3], ["wed", "wed"],
["thu", 4], ["thu", "thu"],
["fri", 5], ["fri", "fri"],
["sat", 6], ["sat", "sat"],
["sun", 7], ["sun", "sun"],
["1", 1], ["1", "mon"],
["2", 2], ["2", "tue"],
["3", 3], ["3", "wed"],
["4", 4], ["4", "thu"],
["5", 5], ["5", "fri"],
["6", 6], ["6", "sat"],
["7", 7], ["7", "sun"],
["0", 7], ["0", "sun"],
[1, 1], [1, "mon"],
[2, 2], [2, "tue"],
[3, 3], [3, "wed"],
[4, 4], [4, "thu"],
[5, 5], [5, "fri"],
[6, 6], [6, "sat"],
[7, 7], [7, "sun"],
[0, 7], [0, "sun"],
]; ];
for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) { for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
assert.sameValue( assert.sameValue(