Skip to content
Open
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 @@ -9,10 +9,10 @@ info: |
Intl.Locale( tag [, options] )

...
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.
22. Let fw be ? GetOption(options, "firstDayOfWeek", string, empty, undefined).
23. If fw is not undefined, then
a. Set fw to WeekdayToUValue(fw).
b. If fw cannot be matched by the type Unicode locale nonterminal, throw a RangeError exception.
...

features: [Intl.Locale,Intl.Locale-info]
Expand All @@ -23,9 +23,30 @@ const invalidFirstDayOfWeekOptions = [
"m",
"mo",
"longerThan8Chars",
"abc\0abc",
"abc?",
"äöü",
"\u6161bc",
8,
9,
10,
-1,
-10,
-100,
-1000,
8n,
9n,
10n,
-1n,
-10n,
-100n,
-1000n,
0.5,
Number.MIN_VALUE,
-Infinity,
];
for (const firstDayOfWeek of invalidFirstDayOfWeekOptions) {
assert.throws(RangeError, function() {
new Intl.Locale('en', {firstDayOfWeek});
new Intl.Locale("en", {firstDayOfWeek});
}, `new Intl.Locale("en", {firstDayOfWeek: "${firstDayOfWeek}"}) throws RangeError`);
}
41 changes: 32 additions & 9 deletions test/intl402/Locale/constructor-options-firstDayOfWeek-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ info: |
Intl.Locale( tag [, options] )

...
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.
22. Let fw be ? GetOption(options, "firstDayOfWeek", string, empty, undefined).
23. If fw is not undefined, then
a. Set fw to WeekdayToUValue(fw).
b. If fw cannot be matched by the type Unicode locale nonterminal, throw a RangeError exception.
24. Set opt.[[fw]] to fw.
...
x. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
35. Let r be MakeLocaleRecord(tag, opt, localeExtensionKeys).
...
x. Set locale.[[FirstDayOfWeek]] to r.[[fw]].
39. Set locale.[[FirstDayOfWeek]] to r.[[fw]].
...

features: [Intl.Locale,Intl.Locale-info]
Expand Down Expand Up @@ -47,9 +47,25 @@ const validFirstDayOfWeekOptions = [
[6, "en-u-fw-sat"],
[7, "en-u-fw-sun"],
[0, "en-u-fw-sun"],
[-0, "en-u-fw-sun"],
[100, "en-u-fw-100"],
[1000, "en-u-fw-1000"],
[1n, "en-u-fw-mon"],
[2n, "en-u-fw-tue"],
[3n, "en-u-fw-wed"],
[4n, "en-u-fw-thu"],
[5n, "en-u-fw-fri"],
[6n, "en-u-fw-sat"],
[7n, "en-u-fw-sun"],
[0n, "en-u-fw-sun"],
[100n, "en-u-fw-100"],
[1000n, "en-u-fw-1000"],
[NaN, "en-u-fw-nan"],
[Infinity, "en-u-fw-infinity"],
[true, "en-u-fw"],
[false, "en-u-fw-false"],
[null, "en-u-fw-null"],
["yes", "en-u-fw-yes"],
["primidi", "en-u-fw-primidi"],
["duodi", "en-u-fw-duodi"],
["tridi", "en-u-fw-tridi"],
Expand All @@ -68,13 +84,20 @@ const validFirstDayOfWeekOptions = [
];
for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
assert.sameValue(
new Intl.Locale('en', { firstDayOfWeek }).toString(),
new Intl.Locale("en", { firstDayOfWeek }).toString(),
expected,
`new Intl.Locale("en", { firstDayOfWeek: ${firstDayOfWeek} }).toString() returns "${expected}"`
);
assert.sameValue(
new Intl.Locale('en-u-fw-WED', { firstDayOfWeek }).toString(),
new Intl.Locale("en-u-fw-WED", { firstDayOfWeek }).toString(),
expected,
`new Intl.Locale("en-u-fw-WED", { firstDayOfWeek: ${firstDayOfWeek} }).toString() returns "${expected}"`
);

let upperCase = String(firstDayOfWeek).toUpperCase();
assert.sameValue(
new Intl.Locale("en", { firstDayOfWeek: upperCase }).toString(),
expected,
`new Intl.Locale("en", { firstDayOfWeek: ${upperCase} }).toString() returns "${expected}"`
);
}
22 changes: 20 additions & 2 deletions test/intl402/Locale/prototype/firstDayOfWeek/valid-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*---
esid: sec-intl.locale
description: >
Checks valid cases for the options argument to the Locale constructor.
Checks valid cases for the locale argument to the Locale constructor.
info: |
Intl.Locale.prototype.firstDayOfWeek
3. Return loc.[[FirstDayOfWeek]].
Expand All @@ -20,11 +20,29 @@ const validIds = [
["en-u-fw-fri", "fri"],
["en-u-fw-sat", "sat"],
["en-u-fw-sun", "sun"],

["en-u-fw", ""],
["en-u-fw-true", ""],
["en-u-fw-false", "false"],
["en-u-fw-yes", "yes"],
["en-u-fw-lunedi", "lunedi"],
["en-u-fw-montag", "montag"],

["en-u-fw-000", "000"],
["en-u-fw-001", "001"],
["en-u-fw-11111111", "11111111"],
];
for (const [id, expected] of validIds) {
assert.sameValue(
new Intl.Locale(id).firstDayOfWeek,
expected,
`new Intl.Locale(${id}).firstDayOfWeek returns "${expected}"`
`new Intl.Locale("${id}").firstDayOfWeek returns "${expected}"`
);

let upperCase = id.toUpperCase();
assert.sameValue(
new Intl.Locale(upperCase).firstDayOfWeek,
expected,
`new Intl.Locale("${upperCase}").firstDayOfWeek returns "${expected}"`
);
}
32 changes: 30 additions & 2 deletions test/intl402/Locale/prototype/firstDayOfWeek/valid-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,44 @@ const validFirstDayOfWeekOptions = [
[6, "sat"],
[7, "sun"],
[0, "sun"],
[-0, "sun"],
[100, "100"],
[1000, "1000"],
[1n, "mon"],
[2n, "tue"],
[3n, "wed"],
[4n, "thu"],
[5n, "fri"],
[6n, "sat"],
[7n, "sun"],
[0n, "sun"],
[100n, "100"],
[1000n, "1000"],
[NaN, "nan"],
[Infinity, "infinity"],
[true, ""],
[false, "false"],
[null, "null"],
["yes", "yes"],
["lunedi", "lunedi"],
["montag", "montag"],
];
for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
assert.sameValue(
new Intl.Locale('en', { firstDayOfWeek }).firstDayOfWeek,
new Intl.Locale("en", { firstDayOfWeek }).firstDayOfWeek,
expected,
`new Intl.Locale("en", { firstDayOfWeek: ${firstDayOfWeek} }).firstDayOfWeek returns "${expected}"`
);
assert.sameValue(
new Intl.Locale('en-u-fw-WED', { firstDayOfWeek }).firstDayOfWeek,
new Intl.Locale("en-u-fw-WED", { firstDayOfWeek }).firstDayOfWeek,
expected,
`new Intl.Locale("en-u-fw-WED", { firstDayOfWeek: ${firstDayOfWeek} }).firstDayOfWeek returns "${expected}"`
);

let upperCase = String(firstDayOfWeek).toUpperCase();
assert.sameValue(
new Intl.Locale("en", { firstDayOfWeek: upperCase }).firstDayOfWeek,
expected,
`new Intl.Locale("en", { firstDayOfWeek: ${upperCase} }).firstDayOfWeek returns "${expected}"`
);
}
Loading