diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/Locale/constructor-tag.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Locale/constructor-tag.js')
-rw-r--r-- | js/src/tests/test262/intl402/Locale/constructor-tag.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/constructor-tag.js b/js/src/tests/test262/intl402/Locale/constructor-tag.js new file mode 100644 index 0000000000..e84fcdbfb5 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/constructor-tag.js @@ -0,0 +1,59 @@ +// 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 ) + 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. + ... + 13. Return CanonicalizeLanguageTag(tag). +features: [Intl.Locale] +---*/ + +const validLanguageTags = { + "eN": "en", + "en-gb": "en-GB", + "IT-LATN-iT": "it-Latn-IT", + "th-th-u-nu-thai": "th-TH-u-nu-thai", + "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", + "DE-1996": "de-1996", // unicode_language_subtag sep unicode_variant_subtag + + // unicode_language_subtag (sep unicode_variant_subtag)* + "sl-ROZAJ-BISKE-1994": "sl-1994-biske-rozaj", + "zh-latn-pinyin-pinyin2": "zh-Latn-pinyin-pinyin2", +}; + +for (const [langtag, canonical] of Object.entries(validLanguageTags)) { + assert.sameValue( + new Intl.Locale(canonical).toString(), + canonical, + `new Intl.Locale("${canonical}").toString() returns "${canonical}"` + ); + assert.sameValue( + new Intl.Locale(langtag).toString(), + canonical, + `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 invalidLanguageTags) { + assert.throws(RangeError, () => new Intl.Locale(langtag)); +} + +reportCompare(0, 0); |