diff --git a/harness/testIntl.js b/harness/testIntl.js index 3b9e62d7cee2adab2390dedc3e80119ccc9bfb61..1a264dbd5c7b92ee2e2652b0a5658ece19b8a88d 100644 --- a/harness/testIntl.js +++ b/harness/testIntl.js @@ -183,6 +183,11 @@ function getInvalidLanguageTags() { "ä¸æ–‡", // non-ASCII letters "en-ß", // non-ASCII letters "ıd", // non-ASCII letters + "es-Latn-latn", // two scripts + "pl-PL-pl", // two regions + "u-ca-gregory", // extension in first place + "de-1996-1996", // duplicate numeric variant + "pt-u-ca-gregory-u-nu-latn", // duplicate singleton subtag // underscores in different parts of the language tag "de_DE", diff --git a/test/intl402/Locale/constructor-options-language-invalid.js b/test/intl402/Locale/constructor-options-language-invalid.js index 6ac5f3e03b94763c9158a09a3f9bc29936e40173..5c593becd8e891eec683ffb744a0e9607e425ba0 100644 --- a/test/intl402/Locale/constructor-options-language-invalid.js +++ b/test/intl402/Locale/constructor-options-language-invalid.js @@ -50,7 +50,8 @@ const invalidLanguageOptions = [ "i-klingon", // Regular grandfathered language tag. - "zh-Hant", + "zh-min", + "zh-min-nan", // Reserved with extended language subtag "abcd-US", diff --git a/test/intl402/Locale/constructor-options-numberingsystem-invalid.js b/test/intl402/Locale/constructor-options-numberingsystem-invalid.js index 21dce50be1424bad8560263336db84ea504cb8d8..60e451ee77709046500bbe572fe8b006612d06d6 100644 --- a/test/intl402/Locale/constructor-options-numberingsystem-invalid.js +++ b/test/intl402/Locale/constructor-options-numberingsystem-invalid.js @@ -1,4 +1,4 @@ -// Copyright 2018 Igalia, S.L. All rights reserved. +// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- @@ -25,6 +25,13 @@ const invalidNumberingSystemOptions = [ "ab", "abcdefghi", "abc-abcdefghi", + "!invalid!", + "-latn-", + "latn-", + "latn--", + "latn-ca", + "latn-ca-", + "latn-ca-gregory", ]; for (const invalidNumberingSystemOption of invalidNumberingSystemOptions) { assert.throws(RangeError, function() { diff --git a/test/intl402/Locale/constructor-tag.js b/test/intl402/Locale/constructor-tag.js new file mode 100644 index 0000000000000000000000000000000000000000..5deab4d6d9c79fa99a8b9994cd18eaa44f140492 --- /dev/null +++ b/test/intl402/Locale/constructor-tag.js @@ -0,0 +1,40 @@ +// 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 canonicalization of specific tags. +info: | + ApplyOptionsToTag( tag, options ) + 10. Return CanonicalizeLanguageTag(tag). +features: [Intl.Locale] +---*/ + +const validLanguageTags = { + "eN": "en", + "en-gb": "en-GB", + "IT-LATN-iT": "it-Latn-IT", + "ar-ma-u-ca-islamicc": "ar-MA-u-ca-islamicc", + "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", + "sl-ROZAJ-BISKE-1994": "sl-rozaj-biske-1994", + "zh-latn-pinyin-pinyin2": "zh-Latn-pinyin-pinyin2", +}; + +for (const [langtag, canonical] of Object.entries(validLanguageTags)) { + assert.sameValue(new Intl.Locale(canonical).toString(), canonical, + `"${canonical}" should pass through unchanged`); + assert.sameValue(new Intl.Locale(langtag).toString(), canonical, + `"${langtag}" should be canonicalized to "${canonical}`); +}