diff --git a/test/intl402/Locale/constructor-options-firstDayOfWeek-invalid.js b/test/intl402/Locale/constructor-options-firstDayOfWeek-invalid.js index 727134d7f93..19b586f8060 100644 --- a/test/intl402/Locale/constructor-options-firstDayOfWeek-invalid.js +++ b/test/intl402/Locale/constructor-options-firstDayOfWeek-invalid.js @@ -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] @@ -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`); } diff --git a/test/intl402/Locale/constructor-options-firstDayOfWeek-valid.js b/test/intl402/Locale/constructor-options-firstDayOfWeek-valid.js index 0c60306257c..723a822047d 100644 --- a/test/intl402/Locale/constructor-options-firstDayOfWeek-valid.js +++ b/test/intl402/Locale/constructor-options-firstDayOfWeek-valid.js @@ -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] @@ -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"], @@ -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}"` + ); } diff --git a/test/intl402/Locale/prototype/firstDayOfWeek/valid-id.js b/test/intl402/Locale/prototype/firstDayOfWeek/valid-id.js index d9aa88a33ba..0df2b4bea9b 100644 --- a/test/intl402/Locale/prototype/firstDayOfWeek/valid-id.js +++ b/test/intl402/Locale/prototype/firstDayOfWeek/valid-id.js @@ -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]]. @@ -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}"` ); } diff --git a/test/intl402/Locale/prototype/firstDayOfWeek/valid-options.js b/test/intl402/Locale/prototype/firstDayOfWeek/valid-options.js index bf6c8507cc5..5dd0ba2342f 100644 --- a/test/intl402/Locale/prototype/firstDayOfWeek/valid-options.js +++ b/test/intl402/Locale/prototype/firstDayOfWeek/valid-options.js @@ -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}"` + ); }