diff --git a/test/intl402/Locale/constructor-tag.js b/test/intl402/Locale/constructor-tag.js index d75ec71d26da994159cb7a5ea688f5e2895804ae..112c09c329660ecc24907073aec4bf5cb268a836 100644 --- a/test/intl402/Locale/constructor-tag.js +++ b/test/intl402/Locale/constructor-tag.js @@ -7,7 +7,9 @@ description: > Verifies canonicalization of specific tags. info: | ApplyOptionsToTag( tag, options ) - 10. Return CanonicalizeLanguageTag(tag). + 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. + ... + 13. Return CanonicalizeLanguageTag(tag). features: [Intl.Locale] ---*/ @@ -16,17 +18,13 @@ const validLanguageTags = { "en-gb": "en-GB", "IT-LATN-iT": "it-Latn-IT", "th-th-u-nu-thai": "th-TH-u-nu-thai", - "X-u-foo": "x-u-foo", "en-x-u-foo": "en-x-u-foo", "en-a-bar-x-u-foo": "en-a-bar-x-u-foo", "en-x-u-foo-a-bar": "en-x-u-foo-a-bar", "en-u-baz-a-bar-x-u-foo": "en-a-bar-u-baz-x-u-foo", - "Flob": "flob", - "ZORK": "zork", - "Blah-latn": "blah-Latn", - "QuuX-latn-us": "quux-Latn-US", - "SPAM-gb-x-Sausages-BACON-eggs": "spam-GB-x-sausages-bacon-eggs", - "DE-1996": "de-1996", + "DE-1996": "de-1996", // unicode_language_subtag sep unicode_variant_subtag + + // unicode_language_subtag (sep unicode_variant_subtag)* "sl-ROZAJ-BISKE-1994": "sl-rozaj-biske-1994", "zh-latn-pinyin-pinyin2": "zh-Latn-pinyin-pinyin2", }; @@ -43,3 +41,17 @@ for (const [langtag, canonical] of Object.entries(validLanguageTags)) { `new Intl.Locale("${langtag}").toString() returns "${canonical}"` ); } + +// unicode_language_subtag = alpha{2,3} | alpha{5,8}; +const invalidLanguageTags = { + "X-u-foo", + "Flob", + "ZORK", + "Blah-latn", + "QuuX-latn-us", + "SPAM-gb-x-Sausages-BACON-eggs", +}; + +for (const langtag of Object.entries(invalidLanguageTags)) { + assert.throws(RangeError, () => new Intl.Locale(langtag)); +} diff --git a/test/intl402/Locale/extensions-private.js b/test/intl402/Locale/extensions-private.js index 565d815b80ec5854ba2fa48d4503cea618bb59aa..3fb7048cd1a5494f7c206e46bc3b6d67ea9383cf 100644 --- a/test/intl402/Locale/extensions-private.js +++ b/test/intl402/Locale/extensions-private.js @@ -8,39 +8,17 @@ description: > info: | ApplyOptionsToTag( tag, options ) + ... 9. If tag matches neither the privateuse nor the grandfathered production, then ... - ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys ) - - ... - 2. If tag matches the privateuse or the grandfathered production, then - a. Let result be a new Record. - b. Repeat for each element key of relevantExtensionKeys in List order, - i. Set result.[[<key>]] to undefined. - c. Set result.[[locale]] to tag. - d. Return result. - ... - 7. Repeat for each element key of relevantExtensionKeys in List order, - e. Let optionsValue be options.[[<key>]]. - f. If optionsValue is not undefined, then - ii. Let value be optionsValue. - iv. Else, - 1. Append the Record{[[Key]]: key, [[Value]]: value} to keywords. - ... - features: [Intl.Locale] ---*/ -const loc = new Intl.Locale("x-default", { +assert.throws(RangeError, () => new Intl.Locale("x-default", { language: "fr", script: "Cyrl", region: "DE", numberingSystem: "latn", -}); -assert.sameValue(loc.toString(), "fr-Cyrl-DE-u-nu-latn"); -assert.sameValue(loc.language, "fr"); -assert.sameValue(loc.script, "Cyrl"); -assert.sameValue(loc.region, "DE"); -assert.sameValue(loc.numberingSystem, "latn"); +})); diff --git a/test/intl402/Locale/getters-privateuse.js b/test/intl402/Locale/getters-privateuse.js deleted file mode 100644 index 76469c5552d904665e9a2e4c9be717abd7dec185..0000000000000000000000000000000000000000 --- a/test/intl402/Locale/getters-privateuse.js +++ /dev/null @@ -1,28 +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: sec-intl.locale -description: > - Verifies getters with privateuse tags. -info: | - get Intl.Locale.prototype.baseName - 4. If locale does not match the langtag production, return locale. - - get Intl.Locale.prototype.language - 4. If locale matches the privateuse or the grandfathered production, return locale. - - get Intl.Locale.prototype.script - 4. If locale matches the privateuse or the grandfathered production, return undefined. - - get Intl.Locale.prototype.region - 4. If locale matches the privateuse or the grandfathered production, return undefined. -features: [Intl.Locale] ----*/ - -// Privateuse only language tag. -var loc = new Intl.Locale("x-private"); -assert.sameValue(loc.baseName, "x-private"); -assert.sameValue(loc.language, "x-private"); -assert.sameValue(loc.script, undefined); -assert.sameValue(loc.region, undefined); diff --git a/test/intl402/Locale/likely-subtags.js b/test/intl402/Locale/likely-subtags.js index b970d7a4d523385dd9dda38e07dd7ff52cf20a0a..42d56a721772aa1d229d9a1ed433d025e5cac4d4 100644 --- a/test/intl402/Locale/likely-subtags.js +++ b/test/intl402/Locale/likely-subtags.js @@ -37,9 +37,6 @@ const testDataMaximal = { "und-419": "es-Latn-419", "und-150": "ru-Cyrl-RU", "und-AT": "de-Latn-AT", - - // privateuse only. - "x-private": "x-private", }; const testDataMinimal = { @@ -65,9 +62,6 @@ const testDataMinimal = { "es-Latn-419": "es-419", "ru-Cyrl-RU": "ru", "de-Latn-AT": "de-AT", - - // privateuse only. - "x-private": "x-private", }; // Add variants, extensions, and privateuse subtags and ensure they don't @@ -105,3 +99,8 @@ for (const [tag, minimal] of Object.entries(testDataMinimal)) { `"${input}".minimize() should be "${output}"`); } } + +// privateuse only. +// "x" in "x-private" does not match unicode_language_subtag +// unicode_language_subtag = alpha{2,3} | alpha{5,8}; +assert.throws(RangeError, () => new Intl.Locale("x-private"));