diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/intl402/Locale/constructor-options-canonicalized.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Locale/constructor-options-canonicalized.js')
-rw-r--r-- | js/src/tests/test262/intl402/Locale/constructor-options-canonicalized.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/constructor-options-canonicalized.js b/js/src/tests/test262/intl402/Locale/constructor-options-canonicalized.js new file mode 100644 index 0000000000..6019635f15 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/constructor-options-canonicalized.js @@ -0,0 +1,71 @@ +// Copyright 2020 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-resolvelocale +description: > + Values provided as properties of the options-argument to the Locale + constructor are converted to canonical form. +info: | + ResolveLocale ( availableLocales, requestedLocales, options, relevantExtensionKeys, localeData ) + + ... + 9.i.iii.1. Let optionsValue be the string optionsValue after performing the algorithm steps to transform Unicode extension values to canonical syntax per Unicode Technical Standard #35 LDML § 3.2.1 Canonical Unicode Locale Identifiers, treating key as ukey and optionsValue as uvalue productions. + 9.i.iii.2. Let optionsValue be the string optionsValue after performing the algorithm steps to replace Unicode extension values with their canonical form per Unicode Technical Standard #35 LDML § 3.2.1 Canonical Unicode Locale Identifiers, treating key as ukey and optionsValue as uvalue productions. + ... + +features: [Intl.Locale] +---*/ + +const keyValueTests = [ + { + key: "ca", + option: "calendar", + tests: [ + ["islamicc", "islamic-civil"], + ["ethiopic-amete-alem", "ethioaa"], + ], + }, +]; + +for (const { key, option, tests } of keyValueTests) { + for (const [noncanonical, canonical] of tests) { + let canonicalInLocale = + new Intl.Locale(`en-u-${key}-${canonical}`); + + assert.sameValue( + canonicalInLocale[option], + canonical, + `new Intl.Locale("en-u-${key}-${canonical}").${option} returns ${canonical}` + ); + + let canonicalInOption = + new Intl.Locale(`en`, { [option]: canonical }); + + assert.sameValue( + canonicalInOption[option], + canonical, + `new Intl.Locale("en", { ${option}: "${canonical}" }).${option} returns ${canonical}` + ); + + let noncanonicalInLocale = + new Intl.Locale(`en-u-${key}-${noncanonical}`); + + assert.sameValue( + noncanonicalInLocale[option], + canonical, + `new Intl.Locale("en-u-${key}-${noncanonical}").${option} returns ${canonical}` + ); + + let noncanonicalInOption = + new Intl.Locale(`en`, { [option]: noncanonical }); + + assert.sameValue( + noncanonicalInOption[option], + canonical, + `new Intl.Locale("en", { ${option}: "${noncanonical}" }).${option} returns ${canonical}` + ); + } +} + +reportCompare(0, 0); |