diff --git a/test/intl402/Locale/constructor-newtarget.js b/test/intl402/Locale/constructor-newtarget-undefined.js similarity index 69% rename from test/intl402/Locale/constructor-newtarget.js rename to test/intl402/Locale/constructor-newtarget-undefined.js index a7246d0cbf157a1a0223f62bf271146bc86c9198..e24be35be472cd26c504a2e7bd9254c2968be208 100644 --- a/test/intl402/Locale/constructor-newtarget.js +++ b/test/intl402/Locale/constructor-newtarget-undefined.js @@ -2,14 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > Verifies the NewTarget check for Intl.Locale. info: | Intl.Locale( tag [, options] ) + 1. If NewTarget is undefined, throw a TypeError exception. features: [Intl.Locale] ---*/ -assert.throws(TypeError, () => Intl.Locale()); -assert.throws(TypeError, () => Intl.Locale("en")); +assert.throws(TypeError, function() { + Intl.Locale(); +}); + +assert.throws(TypeError, function() { + Intl.Locale("en"); +}); diff --git a/test/intl402/Locale/constructor-options-calendar-invalid.js b/test/intl402/Locale/constructor-options-calendar-invalid.js new file mode 100644 index 0000000000000000000000000000000000000000..7722a2ecedcfe4db7e785f2572c82c2a882cec11 --- /dev/null +++ b/test/intl402/Locale/constructor-options-calendar-invalid.js @@ -0,0 +1,36 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + + ... + 15. If calendar is not undefined, then + a. If calendar does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception. + 16. Set opt.[[ca]] to calendar. + +features: [Intl.Locale] +---*/ + + +/* + alphanum = (ALPHA / DIGIT) ; letters and numbers + calendar = (3*8alphanum) *("-" (3*8alphanum)) +*/ +const invalidCalendarOptions = [ + "", + "a", + "ab", + "abcdefghi", + "abc-abcdefghi", +]; +for (const invalidCalendarOption of invalidCalendarOptions) { + assert.throws(RangeError, function() { + new Intl.Locale("en", {calendar: invalidCalendarOption}); + }, `${invalidCalendarOption} is an invalid calendar option value`); +} diff --git a/test/intl402/Locale/constructor-options-calendar-valid.js b/test/intl402/Locale/constructor-options-calendar-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..fbd4f6d741dc4c75e5b31ca8f5ab3c10bf92f139 --- /dev/null +++ b/test/intl402/Locale/constructor-options-calendar-valid.js @@ -0,0 +1,42 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + + ... + 14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined). + ... + +features: [Intl.Locale] +---*/ + +const validCalendarOptions = [ + ["abc", "en-u-ca-abc"], + ["abcd", "en-u-ca-abcd"], + ["abcde", "en-u-ca-abcde"], + ["abcdef", "en-u-ca-abcdef"], + ["abcdefg", "en-u-ca-abcdefg"], + ["abcdefgh", "en-u-ca-abcdefgh"], + ["12345678", "en-u-ca-12345678"], + ["1234abcd", "en-u-ca-1234abcd"], + ["1234abcd-abc123", "en-u-ca-1234abcd-abc123"], +]; +for (const [calendar, expected] of validCalendarOptions) { + let options = { calendar }; + assert.sameValue( + new Intl.Locale('en', options).toString(), + expected, + `new Intl.Locale('en', options).toString() equals the value of ${expected}` + ); + assert.sameValue( + new Intl.Locale('en-u-ca-gregory', options).toString(), + expected, + `new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expected}` + ); +} diff --git a/test/intl402/Locale/constructor-options-language-invalid.js b/test/intl402/Locale/constructor-options-language-invalid.js new file mode 100644 index 0000000000000000000000000000000000000000..6ac5f3e03b94763c9158a09a3f9bc29936e40173 --- /dev/null +++ b/test/intl402/Locale/constructor-options-language-invalid.js @@ -0,0 +1,68 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 4. If language is not undefined, then + a. If language does not match the language production, throw a RangeError exception. + ... + +features: [Intl.Locale] +---*/ + +/* + language = 2*3ALPHA ; shortest ISO 639 code + ["-" extlang] ; sometimes followed by + ; extended language subtags + / 4ALPHA ; or reserved for future use + / 5*8ALPHA ; or registered language subtag + + extlang = 3ALPHA ; selected ISO 639 codes + *2("-" 3ALPHA) ; permanently reserved +*/ +const invalidLanguageOptions = [ + "", + "a", + "ab7", + "notalanguage", + "undefined", + + // Value contains more than just the 'language' production. + "fr-Latn", + "fr-FR", + "sa-vaidika", + "fr-a-asdf", + "fr-x-private", + + // Irregular grandfathered language tag. + "i-klingon", + + // Regular grandfathered language tag. + "zh-Hant", + + // Reserved with extended language subtag + "abcd-US", + "abcde-US", + "abcdef-US", + "abcdefg-US", + "abcdefgh-US", + + 7, +]; +for (const invalidLanguageOption of invalidLanguageOptions) { + assert.throws(RangeError, function() { + new Intl.Locale("en", {language: invalidLanguageOption}); + }, `${invalidLanguageOption} is an invalid language option value`); +} diff --git a/test/intl402/Locale/constructor-options-language-valid.js b/test/intl402/Locale/constructor-options-language-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..bf5c764dd5fd5e5201bb67b498cd5642e35e8af3 --- /dev/null +++ b/test/intl402/Locale/constructor-options-language-valid.js @@ -0,0 +1,44 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 9. If tag matches the langtag production, then + a. If language is not undefined, then + i. Set tag to tag with the substring corresponding to the language production replaced by the string language. + +features: [Intl.Locale] +---*/ + +const validLanguageOptions = [ + [undefined, "en"], + [null, "null"], + ["zh-cmn", "cmn"], + ["ZH-CMN", "cmn"], + ["abcd", "abcd"], + ["abcde", "abcde"], + ["abcdef", "abcdef"], + ["abcdefg", "abcdefg"], + ["abcdefgh", "abcdefgh"], + [{ toString() { return "de" } }, "de"], +]; +for (const [language, expected] of validLanguageOptions) { + let options = { language }; + assert.sameValue( + new Intl.Locale('en', options).toString(), + expected, + `new Intl.Locale('en', options).toString() equals the value of ${expected}` + ); +} diff --git a/test/intl402/Locale/constructor-options-region-invalid.js b/test/intl402/Locale/constructor-options-region-invalid.js new file mode 100644 index 0000000000000000000000000000000000000000..6939c225b98c57f500ff9c210ee584021827d005 --- /dev/null +++ b/test/intl402/Locale/constructor-options-region-invalid.js @@ -0,0 +1,56 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 8. If region is not undefined, then + a. If region does not match the region production, throw a RangeError exception. + ... + +features: [Intl.Locale] +---*/ + +/* + region = 2ALPHA ; ISO 3166-1 code + / 3DIGIT ; UN M.49 code +*/ +const invalidRegionOptions = [ + "", + "a", + "abc", + "a7", + + // Value cannot be parsed as a 'region' production. + "notaregion", + + // Value contains more than just the 'region' production. + "SA-vaidika", + "SA-a-asdf", + "SA-x-private", + + // Value contains more than just the 'script' production. + "ary-Arab", + "Latn-SA", + "Latn-vaidika", + "Latn-a-asdf", + "Latn-x-private", + + 7, +]; +for (const invalidRegionOption of invalidRegionOptions) { + assert.throws(RangeError, function() { + new Intl.Locale("en", {region: invalidRegionOption}); + }, `${invalidRegionOption} is an invalid region option value`); +} diff --git a/test/intl402/Locale/constructor-options-region-valid.js b/test/intl402/Locale/constructor-options-region-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..00d4762736606f8f095b026c7fcdaec315960900 --- /dev/null +++ b/test/intl402/Locale/constructor-options-region-valid.js @@ -0,0 +1,46 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 7. Let region be ? GetOption(options, "region", "string", undefined, undefined). + ... + 9. If tag matches the langtag production, then + ... + c. If region is not undefined, then + i. If tag does not contain a region production, then + 1. Set tag to the concatenation of the language production of tag, the substring corresponding to the "-" script production if present, "-", region, and the rest of tag. + +features: [Intl.Locale] +---*/ + +const validRegionOptions = [ + ["FR", "en-FR"], + ["554", "en-554"], + [554, "en-554"], +]; +for (const [region, expected] of validRegionOptions) { + let options = { region }; + assert.sameValue( + new Intl.Locale('en', options).toString(), + expected, + `new Intl.Locale('en', options).toString() equals the value of ${expected}` + ); + assert.sameValue( + new Intl.Locale('en-US', options).toString(), + expected, + `new Intl.Locale('en-US', options).toString() equals the value of ${expected}` + ); +} diff --git a/test/intl402/Locale/constructor-options-script-invalid.js b/test/intl402/Locale/constructor-options-script-invalid.js new file mode 100644 index 0000000000000000000000000000000000000000..a736280d54824caa43a141c8a39b703cd928c5d6 --- /dev/null +++ b/test/intl402/Locale/constructor-options-script-invalid.js @@ -0,0 +1,52 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 6. If script is not undefined, then + a. If script does not match the script production, throw a RangeError exception. + ... + +features: [Intl.Locale] +---*/ + +/* + script = 4ALPHA ; ISO 15924 code +*/ +const invalidScriptOptions = [ + "", + "a", + "ab", + "abc", + "abc7", + "notascript", + "undefined", + "Bal\u0130", + "Bal\u0131", + + // Value contains more than just the 'script' production. + "ary-Arab", + "Latn-SA", + "Latn-vaidika", + "Latn-a-asdf", + "Latn-x-private", + + 7, +]; +for (const invalidScriptOption of invalidScriptOptions) { + assert.throws(RangeError, function() { + new Intl.Locale("en", {script: invalidScriptOption}); + }, `${invalidScriptOption} is an invalid script option value`); +} diff --git a/test/intl402/Locale/constructor-options-script-valid.js b/test/intl402/Locale/constructor-options-script-valid.js new file mode 100644 index 0000000000000000000000000000000000000000..a9c10a4dd1c074740e7fc7c1e2d1a44f1652b2e0 --- /dev/null +++ b/test/intl402/Locale/constructor-options-script-valid.js @@ -0,0 +1,51 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 5. Let script be ? GetOption(options, "script", "string", undefined, undefined). + ... + 9. If tag matches the langtag production, then + ... + b. If script is not undefined, then + i. If tag does not contain a script production, then + 1. Set tag to the concatenation of the language production of tag, "-", script, and the rest of tag. + ii. Else, + 1. Set tag to tag with the substring corresponding to the script production replaced by the string script. + + +features: [Intl.Locale] +---*/ + +const validScriptOptions = [ + [null, "en-Null"], + ["bali", "en-Bali"], + ["Bali", "en-Bali"], + ["bALI", "en-BALI"], // TODO REVIEW: is this the correct case regularization? + [{ toString() { return "Brai" } }, "en-Brai"], +]; +for (const [script, expected] of validScriptOptions) { + let options = { script }; + assert.sameValue( + new Intl.Locale("en", options).toString(), + expected, + `new Intl.Locale("en", options).toString() equals the value of ${expected}` + ); + assert.sameValue( + new Intl.Locale("en-Cyrl", options).toString(), + expected, + `new Intl.Locale("en-Cyrl", options).toString() equals the value of ${expected}` + ); +} diff --git a/test/intl402/Locale/constructor-options.js b/test/intl402/Locale/constructor-options.js deleted file mode 100644 index 32e7a8443d2464b4f865964223e5447ff12a6bc6..0000000000000000000000000000000000000000 --- a/test/intl402/Locale/constructor-options.js +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: pending -description: > - Checks error cases for the options argument to the Locale - constructor. -info: | - Intl.Locale( tag [, options] ) - 10. If options is undefined, then - 11. Else - a. Let options be ? ToObject(options). - 12. Set tag to ? ApplyOptionsToTag(tag, options). - 14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined). - 15. If calendar is not undefined, then - a. If calendar does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception. - 16. Set opt.[[ca]] to calendar. - - ApplyOptionsToTag( tag, options ) - 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. - 3. Let language be ? GetOption(options, "language", "string", undefined, undefined). - 4. If language is not undefined, then - a. If language does not match the language production, throw a RangeError exception. - 5. Let script be ? GetOption(options, "script", "string", undefined, undefined). - 6. If script is not undefined, then - a. If script does not match the script production, throw a RangeError exception. - 7. Let region be ? GetOption(options, "region", "string", undefined, undefined). - 8. If region is not undefined, then - a. If region does not match the region production, throw a RangeError exception. - 9. If tag matches the langtag production, then - a. If language is not undefined, then - i. Set tag to tag with the substring corresponding to the language production replaced by the string language. - b. If script is not undefined, then - i. If tag does not contain a script production, then - 1. Set tag to the concatenation of the language production of tag, "-", script, and the rest of tag. - ii. Else, - 1. Set tag to tag with the substring corresponding to the script production replaced by the string script. - c. If region is not undefined, then - i. If tag does not contain a region production, then - 1. Set tag to the concatenation of the language production of tag, the substring corresponding to the "-" script production if present, "-", region, and the rest of tag. - ii. Else, - 1. Set tag to tag with the substring corresponding to the region production replaced by the string region. - 10. Return CanonicalizeLanguageTag(tag). -includes: [testIntl.js, compareArray.js] -features: [Intl.Locale] ----*/ - -// Intl.Locale step 11.a. -assert.throws(TypeError, function() { new Intl.Locale("en", null) }) - - -// ApplyOptionsToTag step 2. -for (const invalidTag of getInvalidLanguageTags()) { - assert.throws(RangeError, function() { - new Intl.Locale(invalidTag) - }, "Language tag: " + invalidTag); -} - - -// ApplyOptionsToTag step 3, 9.a.i. -const validLanguageOptions = [ - [undefined, "en"], - [null, "null"], - ["zh-cmn", "cmn"], - ["ZH-CMN", "cmn"], - ["abcd", "abcd"], - ["abcde", "abcde"], - ["abcdef", "abcdef"], - ["abcdefg", "abcdefg"], - ["abcdefgh", "abcdefgh"], - [{ toString() { return "de" } }, "de"], -]; -for (const [option, expected] of validLanguageOptions) { - assert.sameValue(new Intl.Locale("en", { - language: option, - }).toString(), expected); -} - - -// ApplyOptionsToTag step 4.a. -/* - language = 2*3ALPHA ; shortest ISO 639 code - ["-" extlang] ; sometimes followed by - ; extended language subtags - / 4ALPHA ; or reserved for future use - / 5*8ALPHA ; or registered language subtag - - extlang = 3ALPHA ; selected ISO 639 codes - *2("-" 3ALPHA) ; permanently reserved -*/ -const invalidLanguageOptions = [ - "", - "a", - "ab7", - "notalanguage", - "undefined", - - // Value contains more than just the 'language' production. - "fr-Latn", - "fr-FR", - "sa-vaidika", - "fr-a-asdf", - "fr-x-private", - - // Irregular grandfathered language tag. - "i-klingon", - - // Regular grandfathered language tag. - "zh-Hant", - - // Reserved with extended language subtag - "abcd-US", - "abcde-US", - "abcdef-US", - "abcdefg-US", - "abcdefgh-US", - - 7, -]; -for (const invalidLanguageOption of invalidLanguageOptions) { - assert.throws(RangeError, () => new Intl.Locale("en", {language: invalidLanguageOption})); -} - - -// ApplyOptionsToTag step 5, 9.b. -const validScriptOptions = [ - [null, "en-Null"], - ["bali", "en-Bali"], - ["Bali", "en-Bali"], - ["bALI", "en-BALI"], // TODO REVIEW: is this the correct case regularization? - [{ toString() { return "Brai" } }, "en-Brai"], -]; -for (const [option, expected] of validScriptOptions) { - assert.sameValue(new Intl.Locale("en", { - script: option, - }).toString(), expected); - assert.sameValue(new Intl.Locale("en-Cyrl", { - script: option, - }).toString(), expected); -} - - -// ApplyOptionsToTag step 6.a. -/* - script = 4ALPHA ; ISO 15924 code -*/ -const invalidScriptOptions = [ - "", - "a", - "ab", - "abc", - "abc7", - "notascript", - "undefined", - "Bal\u0130", - "Bal\u0131", - - // Value contains more than just the 'script' production. - "ary-Arab", - "Latn-SA", - "Latn-vaidika", - "Latn-a-asdf", - "Latn-x-private", - - 7, -]; -for (const invalidScriptOption of invalidScriptOptions) { - assert.throws(RangeError, () => new Intl.Locale("en", {script: invalidScriptOption})); -} - - -// ApplyOptionsToTag step 7, 9.c. -const validRegionOptions = [ - ["FR", "en-FR"], - ["554", "en-554"], - [554, "en-554"], -]; -for (const [option, expected] of validRegionOptions) { - assert.sameValue(new Intl.Locale("en", { - region: option, - }).toString(), expected); - assert.sameValue(new Intl.Locale("en-US", { - region: option, - }).toString(), expected); -} - - -// ApplyOptionsToTag step 8.a. -/* - region = 2ALPHA ; ISO 3166-1 code - / 3DIGIT ; UN M.49 code -*/ -const invalidRegionOptions = [ - "", - "a", - "abc", - "a7", - - // Value cannot be parsed as a 'region' production. - "notaregion", - - // Value contains more than just the 'region' production. - "SA-vaidika", - "SA-a-asdf", - "SA-x-private", - - // Value contains more than just the 'script' production. - "ary-Arab", - "Latn-SA", - "Latn-vaidika", - "Latn-a-asdf", - "Latn-x-private", - - 7, -]; -for (const invalidRegionOption of invalidRegionOptions) { - assert.throws(RangeError, () => new Intl.Locale("en", {region: invalidRegionOption})); -} - - -// Intl.Locale step 14. -const validCalendarOptions = [ - ["abc", "en-u-ca-abc"], - ["abcd", "en-u-ca-abcd"], - ["abcde", "en-u-ca-abcde"], - ["abcdef", "en-u-ca-abcdef"], - ["abcdefg", "en-u-ca-abcdefg"], - ["abcdefgh", "en-u-ca-abcdefgh"], - ["12345678", "en-u-ca-12345678"], - ["1234abcd", "en-u-ca-1234abcd"], - ["1234abcd-abc123", "en-u-ca-1234abcd-abc123"], -]; -for (const [option, expected] of validCalendarOptions) { - assert.sameValue(new Intl.Locale("en", { - calendar: option, - }).toString(), expected); - assert.sameValue(new Intl.Locale("en-u-ca-gregory", { - calendar: option, - }).toString(), expected); -} - - -// Intl.Locale step 15. -/* - alphanum = (ALPHA / DIGIT) ; letters and numbers - calendar = (3*8alphanum) *("-" (3*8alphanum)) -*/ -const invalidCalendarOptions = [ - "", - "a", - "ab", - "abcdefghi", - "abc-abcdefghi", -]; -for (const invalidCalendarOption of invalidCalendarOptions) { - assert.throws(RangeError, () => new Intl.Locale("en", {calendar: invalidCalendarOption})); -} diff --git a/test/intl402/Locale/function-prototype.js b/test/intl402/Locale/function-prototype.js new file mode 100644 index 0000000000000000000000000000000000000000..044ecfa33d26e7540eb960646a02ecd4584ce820 --- /dev/null +++ b/test/intl402/Locale/function-prototype.js @@ -0,0 +1,16 @@ +// Copyright 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + The value of the [[Prototype]] internal slot of the Intl.Locale constructor is the + intrinsic object %FunctionPrototype%. +features: [Intl.Locale] +---*/ + +assert.sameValue( + Object.getPrototypeOf(Intl.Locale), + Function.prototype, + "Object.getPrototypeOf(Intl.Locale) equals the value of Function.prototype" +); diff --git a/test/intl402/Locale/instance-extensibility.js b/test/intl402/Locale/instance-extensibility.js new file mode 100644 index 0000000000000000000000000000000000000000..41ac73c1feb6ca0d4f8f540d6dfca7e6e81aafb0 --- /dev/null +++ b/test/intl402/Locale/instance-extensibility.js @@ -0,0 +1,20 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Intl.Locale instance object extensibility +info: | + 17 ECMAScript Standard Built-in Objects: + + Unless specified otherwise, the [[Extensible]] internal slot + of a built-in object initially has the value true. +features: [Intl.Locale] +---*/ + +assert.sameValue( + Object.isExtensible(new Intl.Locale('en')), + true, + "Object.isExtensible(new Intl.Locale('en')) returns true" +); diff --git a/test/intl402/Locale/instance-properties.js b/test/intl402/Locale/instance-properties.js deleted file mode 100644 index 8ed25e297ef2106ae21036786f8c753a35127d40..0000000000000000000000000000000000000000 --- a/test/intl402/Locale/instance-properties.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: pending -description: > - Verifies the properties of a Locale instance. -info: | - Intl.Locale( tag [, options] ) - 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, %LocalePrototype%, internalSlotsList). -features: [Intl.Locale] ----*/ - -const value = new Intl.Locale("en"); -assert.sameValue(Object.getPrototypeOf(value), Intl.Locale.prototype); -assert.sameValue(Object.isExtensible(value), true); diff --git a/test/intl402/Locale/instance.js b/test/intl402/Locale/instance.js new file mode 100644 index 0000000000000000000000000000000000000000..11dc3f225f9726a0f02779a97259504ce8d62efa --- /dev/null +++ b/test/intl402/Locale/instance.js @@ -0,0 +1,22 @@ +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Intl.Locale instance object created from %LocalePrototype%. +info: | + Intl.Locale( tag [, options] ) + + 6. Let locale be ? + OrdinaryCreateFromConstructor(NewTarget, %LocalePrototype%, + internalSlotsList). +features: [Intl.Locale] +---*/ + +const value = new Intl.Locale('en'); +assert.sameValue( + Object.getPrototypeOf(value), + Intl.Locale.prototype, + "Object.getPrototypeOf(value) equals the value of Intl.Locale.prototype" +); diff --git a/test/intl402/Locale/invalid-tag-throws-boolean.js b/test/intl402/Locale/invalid-tag-throws-boolean.js index 1d9f3173435f694aec271eace896af277f99e988..ce6937e2ea60a20ea3e62f23ddd04cb495fd8109 100644 --- a/test/intl402/Locale/invalid-tag-throws-boolean.js +++ b/test/intl402/Locale/invalid-tag-throws-boolean.js @@ -2,20 +2,19 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > - Verifies the type check on the tag argument to Intl.Locale. + Verifies the type check on the tag argument to Intl.Locale. info: | - Intl.Locale( tag [, options] ) - 7. If Type(tag) is not String or Object, throw a TypeError exception. + Intl.Locale( tag [, options] ) + + 7. If Type(tag) is not String or Object, throw a TypeError exception. features: [Intl.Locale] ---*/ -const boolean_values = [ - true, - false, -]; - -for (const boolean_value of boolean_values) { - assert.throws(TypeError, () => new Intl.Locale(boolean_value)); -} +assert.throws(TypeError, function() { + new Intl.Locale(true); +}, "true is an invalid tag value"); +assert.throws(TypeError, function() { + new Intl.Locale(false); +}, "false is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-null.js b/test/intl402/Locale/invalid-tag-throws-null.js index c86de2242e20c62b81d6a8ada6354a631ab0bb1d..6d08c26286aa2c0b003aeb14eaae03ea1c12f2e2 100644 --- a/test/intl402/Locale/invalid-tag-throws-null.js +++ b/test/intl402/Locale/invalid-tag-throws-null.js @@ -2,13 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > - Verifies the type check on the tag argument to Intl.Locale. + Verifies the type check on the tag argument to Intl.Locale. info: | - Intl.Locale( tag [, options] ) - 7. If Type(tag) is not String or Object, throw a TypeError exception. + Intl.Locale( tag [, options] ) + + 7. If Type(tag) is not String or Object, throw a TypeError exception. features: [Intl.Locale] ---*/ -assert.throws(TypeError, () => new Intl.Locale(null)); +assert.throws(TypeError, function() { + new Intl.Locale(null); +}, "null is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-number.js b/test/intl402/Locale/invalid-tag-throws-number.js index 62c35edf21305636bc7f72d13050fd2d8fb938d4..805d36c525e4bf8c0199202c8337fcf287032fa7 100644 --- a/test/intl402/Locale/invalid-tag-throws-number.js +++ b/test/intl402/Locale/invalid-tag-throws-number.js @@ -2,19 +2,29 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > Verifies the type check on the tag argument to Intl.Locale. info: | Intl.Locale( tag [, options] ) + 7. If Type(tag) is not String or Object, throw a TypeError exception. features: [Intl.Locale] ---*/ -const invalid_type_values = [ - 0, 1.5, Infinity, -Infinity, NaN, -]; +assert.throws(TypeError, function() { + new Intl.Locale(0); +}, "0 is an invalid tag value"); + +assert.throws(TypeError, function() { + new Intl.Locale(1); +}, "1 is an invalid tag value"); + +assert.throws(TypeError, function() { + new Intl.Locale(Infinity); +}, "Infinity is an invalid tag value"); + +assert.throws(TypeError, function() { + new Intl.Locale(NaN); +}, "NaN is an invalid tag value"); -for (const invalid_type_value of invalid_type_values) { - assert.throws(TypeError, () => new Intl.Locale(invalid_type_value)); -} diff --git a/test/intl402/Locale/invalid-tag-throws-symbol.js b/test/intl402/Locale/invalid-tag-throws-symbol.js index 45ed1b63911e50205769611e1cc6e500c4fd7037..a56882e47b14b096378e0e97999b0b38cb62234d 100644 --- a/test/intl402/Locale/invalid-tag-throws-symbol.js +++ b/test/intl402/Locale/invalid-tag-throws-symbol.js @@ -2,14 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > Verifies the type check on the tag argument to Intl.Locale. info: | Intl.Locale( tag [, options] ) + 7. If Type(tag) is not String or Object, throw a TypeError exception. features: [Intl.Locale] ---*/ -const symbol = Symbol(); -assert.throws(TypeError, () => new Intl.Locale(symbol)); +assert.throws(TypeError, function() { + new Intl.Locale(Symbol()); +}, "Symbol() is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws-undefined.js b/test/intl402/Locale/invalid-tag-throws-undefined.js index f4685833bdfc0df21410ab8440b1ec47fe154184..609c20b38439a01077532e19b85ea856474da11a 100644 --- a/test/intl402/Locale/invalid-tag-throws-undefined.js +++ b/test/intl402/Locale/invalid-tag-throws-undefined.js @@ -2,14 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > Verifies the type check on the tag argument to Intl.Locale. info: | Intl.Locale( tag [, options] ) + 7. If Type(tag) is not String or Object, throw a TypeError exception. features: [Intl.Locale] ---*/ -assert.throws(TypeError, () => new Intl.Locale()); -assert.throws(TypeError, () => new Intl.Locale(undefined)); +assert.throws(TypeError, function() { + new Intl.Locale(); +}, "(empty) is an invalid tag value"); + +assert.throws(TypeError, function() { + new Intl.Locale(undefined) +}, "undefined is an invalid tag value"); diff --git a/test/intl402/Locale/invalid-tag-throws.js b/test/intl402/Locale/invalid-tag-throws.js new file mode 100644 index 0000000000000000000000000000000000000000..ee6449510f18f41ecef442b5a0d7b74118ec9583 --- /dev/null +++ b/test/intl402/Locale/invalid-tag-throws.js @@ -0,0 +1,38 @@ +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale +description: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + + ... + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + ... + + ApplyOptionsToTag( tag, options ) + + ... + 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. + ... +includes: [testIntl.js] +features: [Intl.Locale] +---*/ + +// Intl.Locale step 11.a. +assert.throws(TypeError, function() { new Intl.Locale("en", null) }) + + +// ApplyOptionsToTag step 2. +for (const invalidTag of getInvalidLanguageTags()) { + assert.throws(RangeError, function() { + new Intl.Locale(invalidTag); + }, `${invalidTag} is an invalid tag value`); +} + + diff --git a/test/intl402/Locale/length.js b/test/intl402/Locale/length.js index c3bd3dd935d149774bce9b50d95c801372f7fa91..256eb377b23af0f2d7352c7c1f4138c3647d786e 100644 --- a/test/intl402/Locale/length.js +++ b/test/intl402/Locale/length.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > Checks the "length" property of the Locale constructor. info: | @@ -10,11 +10,13 @@ info: | The Locale constructor is a standard built-in property of the Intl object. Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count. Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] features: [Intl.Locale] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale, "length"); -assert.sameValue(propdesc.writable, false); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, true); -assert.sameValue(propdesc.value, 1); +verifyProperty(Intl.Locale, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/intl402/Locale/name.js b/test/intl402/Locale/name.js index 562a9253db50d930e13b07a42c5f8721e5616055..30689c7b09c9717ad936c3579ec688e2dc0e0ea0 100644 --- a/test/intl402/Locale/name.js +++ b/test/intl402/Locale/name.js @@ -2,18 +2,20 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > Checks the "name" property of the Locale constructor. info: | Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification. Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] features: [Intl.Locale] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale, "name"); -assert.sameValue(propdesc.writable, false); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, true); -assert.sameValue(propdesc.value, "Locale"); +verifyProperty(Intl.Locale, "name", { + value: "Locale", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/intl402/Locale/prop-desc.js b/test/intl402/Locale/prop-desc.js index 5a086e66fc0d5eebe1c6bdbc963c96af897fa23f..7be47a352c50bda545d8127f69e53cb8d5532da0 100644 --- a/test/intl402/Locale/prop-desc.js +++ b/test/intl402/Locale/prop-desc.js @@ -2,21 +2,25 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale description: > - Checks the properties of the Locale constructor. + The value of the [[Prototype]] internal slot of the Intl.Locale constructor is the + intrinsic object %FunctionPrototype%. info: | - Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. - Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. - The Locale constructor is a standard built-in property of the Intl object. + The value of Intl.Locale.prototype is %LocalePrototype%. + + This property has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. + +includes: [propertyHelper.js] features: [Intl.Locale] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl, "Locale"); -assert.sameValue(propdesc.writable, true); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, true); -assert.sameValue(propdesc.value, Intl.Locale); +assert.sameValue(typeof Intl.Locale, "function", "typeof Intl.Locale is function"); -assert.sameValue(typeof Intl.Locale, "function"); -assert.sameValue(Object.getPrototypeOf(Intl.Locale), Function.prototype); +verifyProperty(Intl, "Locale", { + value: Intl.Locale, + writable: false, + enumerable: false, + configurable: false, +}); diff --git a/test/intl402/Locale/prototype/constructor.js b/test/intl402/Locale/prototype/constructor.js index 036bccbda744042c1a91f60ec259da1af3a2c4bd..e2c7c95dd72cb77f00a09b4d2c1a3963d8f1350b 100644 --- a/test/intl402/Locale/prototype/constructor.js +++ b/test/intl402/Locale/prototype/constructor.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale.prototype.constructor description: > Checks the "constructor" property of the Locale prototype object. info: | @@ -13,11 +13,13 @@ info: | Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] features: [Intl.Locale] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "constructor"); -assert.sameValue(propdesc.writable, true); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, true); -assert.sameValue(propdesc.value, Intl.Locale); +verifyProperty(Intl.Locale.prototype, 'constructor', { + value: Intl.Locale, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/intl402/Locale/prototype/maximize/length.js b/test/intl402/Locale/prototype/maximize/length.js new file mode 100644 index 0000000000000000000000000000000000000000..dc59be0d579d361c22952e01704373f2be4d03f5 --- /dev/null +++ b/test/intl402/Locale/prototype/maximize/length.js @@ -0,0 +1,22 @@ +// Copyright 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale.prototype.maximize +description: > + Checks the "length" property of Intl.Locale.prototype.maximize(). +info: | + Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. + The Locale constructor is a standard built-in property of the Intl object. + Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count. + Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Intl.Locale] +---*/ + +verifyProperty(Intl.Locale.prototype.maximize, 'length', { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/intl402/Locale/prototype/maximize/name.js b/test/intl402/Locale/prototype/maximize/name.js new file mode 100644 index 0000000000000000000000000000000000000000..45af040eb2c72baca67219019ef0a80141adf54f --- /dev/null +++ b/test/intl402/Locale/prototype/maximize/name.js @@ -0,0 +1,21 @@ +// Copyright 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.locale.prototype.maximize +description: > + Checks the "name" property of Intl.Locale.prototype.maximize(). +info: | + Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. + Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification. + Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Intl.Locale] +---*/ + +verifyProperty(Intl.Locale.prototype.maximize, 'name', { + value: 'maximize', + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/intl402/Locale/prototype/maximize-propdesc.js b/test/intl402/Locale/prototype/maximize/prop-desc.js similarity index 71% rename from test/intl402/Locale/prototype/maximize-propdesc.js rename to test/intl402/Locale/prototype/maximize/prop-desc.js index 61081154157bd07661fd659df911d59c1c3cbce9..c5ff64d6e447705de180cc6d1d1245c061020f36 100644 --- a/test/intl402/Locale/prototype/maximize-propdesc.js +++ b/test/intl402/Locale/prototype/maximize/prop-desc.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale.prototype.maximize description: > Checks the "maximize" property of the Locale prototype object. info: | @@ -11,11 +11,19 @@ info: | Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] features: [Intl.Locale] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "maximize"); -assert.sameValue(propdesc.writable, true); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, true); -assert.sameValue(typeof propdesc.value, "function"); +assert.sameValue( + typeof Intl.Locale.prototype.maximize, + 'function', + "typeof Intl.Locale.prototype.maximize is function" +); + +verifyProperty(Intl.Locale.prototype, 'maximize', { + writable: true, + enumerable: false, + configurable: false, +}); + diff --git a/test/intl402/Locale/prototype/prop-desc.js b/test/intl402/Locale/prototype/prop-desc.js index fc464eeceedb9538d58f7af3a3d9d5c872d6114f..5389b26356e30d7294ddaac43799598b8bd27807 100644 --- a/test/intl402/Locale/prototype/prop-desc.js +++ b/test/intl402/Locale/prototype/prop-desc.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale.prototype description: > Checks the "prototype" property of the Locale constructor. info: | @@ -11,12 +11,12 @@ info: | The value of Intl.Locale.prototype is %LocalePrototype%. This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. +includes: [propertyHelper.js] features: [Intl.Locale] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale, "prototype"); -assert.sameValue(propdesc.writable, false); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, false); -assert.sameValue(typeof propdesc.value, "object"); -assert.notSameValue(propdesc.value, null); +verifyProperty(Intl.Locale, 'prototype', { + writable: false, + enumerable: false, + configurable: false, +}); diff --git a/test/intl402/Locale/prototype/toStringTag.js b/test/intl402/Locale/prototype/toStringTag.js index 8828d2a69c8d9b83aeb5a9da15cee4bd8d56deb0..dd939b574f8e780a622ecba9c87544b67478c93e 100644 --- a/test/intl402/Locale/prototype/toStringTag.js +++ b/test/intl402/Locale/prototype/toStringTag.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: pending +esid: sec-intl.locale.prototype-@@tostringtag description: > Checks the @@toStringTag property of the Locale prototype object. info: | @@ -11,11 +11,13 @@ info: | The initial value of the @@toStringTag property is the string value "Intl.Locale". This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] features: [Intl.Locale, Symbol.toStringTag] ---*/ -const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, Symbol.toStringTag); -assert.sameValue(propdesc.writable, false); -assert.sameValue(propdesc.enumerable, false); -assert.sameValue(propdesc.configurable, true); -assert.sameValue(propdesc.value, "Intl.Locale"); +verifyProperty(Intl.Locale.prototype, Symbol.toStringTag, { + value: 'Intl.Locale', + writable: false, + enumerable: false, + configurable: true +});