diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/intl402/Locale/constructor-parse-twice.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Locale/constructor-parse-twice.js')
-rw-r--r-- | js/src/tests/test262/intl402/Locale/constructor-parse-twice.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/constructor-parse-twice.js b/js/src/tests/test262/intl402/Locale/constructor-parse-twice.js new file mode 100644 index 0000000000..361c2d107d --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/constructor-parse-twice.js @@ -0,0 +1,60 @@ +// 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 the handling of options with grandfathered tags. +info: | + Intl.Locale( tag [, options] ) + 12. Set tag to ? ApplyOptionsToTag(tag, options). + 14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined). + 16. Set opt.[[ca]] to calendar. + 30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys). + + ApplyOptionsToTag( tag, options ) + ... + 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. + + IsStructurallyValidLanguageTag ( locale ) + + The IsStructurallyValidLanguageTag abstract operation verifies that the + locale argument (which must be a String value) + + represents a well-formed Unicode BCP 47 Locale Identifier" as specified in + Unicode Technical Standard 35 section 3.2, or successor, + +features: [Intl.Locale] +---*/ + +const testData = [ + // Canonicalized version of "en-GB-oed", which we can add "US" to right away. + { + tag: "en-GB-oxendict", + options: { + region: "US", + calendar: "gregory", + }, + canonical: "en-US-oxendict-u-ca-gregory", + }, +]; + +for (const {tag, options, canonical} of testData) { + assert.sameValue( + new Intl.Locale(tag, options).toString(), + canonical, + `new Intl.Locale("${tag}", ${options}).toString() returns "${canonical}"` + ); +} + +assert.throws(RangeError, () => + new Intl.Locale("no-bok", {region: "NO", calendar: "gregory"})); +assert.throws(RangeError, () => + new Intl.Locale("no-bok", {region: "SE", calendar: "gregory"})); +assert.throws(RangeError, () => + new Intl.Locale("no-bok-NO", {region: "SE", calendar: "gregory"})); +assert.throws(RangeError, () => + new Intl.Locale("no-bok-SE", {region: "NO", calendar: "gregory"})); + + +reportCompare(0, 0); |