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-region-invalid.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.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-region-invalid.js')
-rw-r--r-- | js/src/tests/test262/intl402/Locale/constructor-options-region-invalid.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Locale/constructor-options-region-invalid.js b/js/src/tests/test262/intl402/Locale/constructor-options-region-invalid.js new file mode 100644 index 0000000000..5f5444b6b5 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/constructor-options-region-invalid.js @@ -0,0 +1,58 @@ +// 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: > + Checks error cases for the options argument to the Locale + constructor. +info: | + Intl.Locale( tag [, options] ) + 10. If options is undefined, then + 11. Else + a. Let options be ? ToObject(options). + 12. Set tag to ? ApplyOptionsToTag(tag, options). + + ApplyOptionsToTag( tag, options ) + ... + 8. If region is not undefined, then + a. If region does not match the region production, throw a RangeError exception. + ... + +features: [Intl.Locale] +---*/ + +/* + region = 2ALPHA ; ISO 3166-1 code + / 3DIGIT ; UN M.49 code +*/ +const invalidRegionOptions = [ + "", + "a", + "abc", + "a7", + + // Value cannot be parsed as a 'region' production. + "notaregion", + + // Value contains more than just the 'region' production. + "SA-vaidika", + "SA-a-asdf", + "SA-x-private", + + // Value contains more than just the 'script' production. + "ary-Arab", + "Latn-SA", + "Latn-vaidika", + "Latn-a-asdf", + "Latn-x-private", + + 7, +]; +for (const region of invalidRegionOptions) { + assert.throws(RangeError, function() { + new Intl.Locale("en", {region}); + }, `new Intl.Locale("en", {region: "${region}"}) throws RangeError`); +} + +reportCompare(0, 0); |