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/DisplayNames/prototype/of | |
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/DisplayNames/prototype/of')
9 files changed, 406 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/browser.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/browser.js diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/shell.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/shell.js diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-calendar-invalid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-calendar-invalid.js new file mode 100644 index 0000000000..1d7fc9ff43 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-calendar-invalid.js @@ -0,0 +1,63 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Throws a RangeError for invalid `calendar` codes +features: [Intl.DisplayNames-v2] +---*/ + +var displayNames = new Intl.DisplayNames(undefined, {type: 'calendar'}); + +assert.throws(RangeError, function() { + displayNames.of('00'); +}, 'insufficient length'); + +assert.throws(RangeError, function() { + displayNames.of('000000000'); +}, 'excessive length'); + +assert.throws(RangeError, function() { + displayNames.of('-00000000'); +}, 'leading separator (dash)'); + +assert.throws(RangeError, function() { + displayNames.of('_00000000'); +}, 'leading separator (underscore)'); + +assert.throws(RangeError, function() { + displayNames.of('00000000-'); +}, 'trailing separator (dash)'); + +assert.throws(RangeError, function() { + displayNames.of('00000000_'); +}, 'trailing separator (underscore)'); + +assert.throws(RangeError, function() { + displayNames.of(' abcdef'); +}, 'leading space'); + +assert.throws(RangeError, function() { + displayNames.of('abcdef '); +}, 'trailing space'); + +assert.throws(RangeError, function() { + displayNames.of('abc def'); +}, 'interstitial space'); + +assert.throws(RangeError, function() { + displayNames.of('123_abc'); +}, '2 segments, minimum length, underscore'); + +assert.throws(RangeError, function() { + displayNames.of('12345678_abcdefgh'); +}, '2 segments, maximum length, underscore'); + +assert.throws(RangeError, function() { + displayNames.of('123_abc_ABC'); +}, '3 segments, minimum length, underscore'); + +assert.throws(RangeError, function() { + displayNames.of('12345678_abcdefgh_ABCDEFGH'); +}, '3 segments, maximum length, underscore'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-calendar-valid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-calendar-valid.js new file mode 100644 index 0000000000..9f6bb2a8d1 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-calendar-valid.js @@ -0,0 +1,29 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Returns string value for valid `calendar` codes +features: [Intl.DisplayNames-v2] +---*/ + +var displayNames = new Intl.DisplayNames(undefined, {type: 'calendar'}); + +assert.sameValue(typeof displayNames.of('01234567'), 'string', '[0-7]'); +assert.sameValue(typeof displayNames.of('899'), 'string', '[89]'); + +assert.sameValue(typeof displayNames.of('abcdefgh'), 'string', '[a-h]'); +assert.sameValue(typeof displayNames.of('ijklmnop'), 'string', '[i-p]'); +assert.sameValue(typeof displayNames.of('qrstuvwx'), 'string', '[q-x]'); +assert.sameValue(typeof displayNames.of('yzz'), 'string', '[yz]'); + +assert.sameValue(typeof displayNames.of('ABCDEFGH'), 'string', '[A-H]'); +assert.sameValue(typeof displayNames.of('IJKLMNOP'), 'string', '[I-P]'); +assert.sameValue(typeof displayNames.of('QRSTUVWX'), 'string', '[Q-X]'); +assert.sameValue(typeof displayNames.of('YZZ'), 'string', '[YZ]'); + +assert.sameValue(typeof displayNames.of('123-abc'), 'string', '2 segments, minimum length, dash'); +assert.sameValue(typeof displayNames.of('12345678-abcdefgh'), 'string', '2 segments, maximum length, dash'); +assert.sameValue(typeof displayNames.of('123-abc-ABC'), 'string', '3 segments, minimum length, dash'); +assert.sameValue(typeof displayNames.of('12345678-abcdefgh-ABCDEFGH'), 'string', '3 segments, maximum length, dash'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-invalid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-invalid.js new file mode 100644 index 0000000000..b1532a389c --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-invalid.js @@ -0,0 +1,39 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Throws a RangeError for invalid `dateTimeField` codes +features: [Intl.DisplayNames-v2] +---*/ + +var displayNames = new Intl.DisplayNames(undefined, {type: 'dateTimeField'}); + +assert.throws(RangeError, function() { + displayNames.of(''); +}, 'empty string'); + +assert.throws(RangeError, function() { + displayNames.of('timezoneName'); +}, 'timezoneName'); + +assert.throws(RangeError, function() { + displayNames.of('timezonename'); +}, 'timezonename'); + +assert.throws(RangeError, function() { + displayNames.of('millisecond'); +}, 'millisecond'); + +assert.throws(RangeError, function() { + displayNames.of('seconds'); +}, 'seconds'); + +assert.throws(RangeError, function() { + displayNames.of(' year'); +}, 'year (with leading space)'); + +assert.throws(RangeError, function() { + displayNames.of('year '); +}, 'year (with trailing space)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-valid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-valid.js new file mode 100644 index 0000000000..d649742ed5 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-valid.js @@ -0,0 +1,24 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Returns string value for valid `dateTimeField` codes +features: [Intl.DisplayNames-v2] +---*/ + +var displayNames = new Intl.DisplayNames(undefined, {type: 'dateTimeField'}); + +assert.sameValue(typeof displayNames.of('era'), 'string', 'era'); +assert.sameValue(typeof displayNames.of('year'), 'string', 'year'); +assert.sameValue(typeof displayNames.of('quarter'), 'string', 'quarter'); +assert.sameValue(typeof displayNames.of('month'), 'string', 'month'); +assert.sameValue(typeof displayNames.of('weekOfYear'), 'string', 'weekOfYear'); +assert.sameValue(typeof displayNames.of('weekday'), 'string', 'weekday'); +assert.sameValue(typeof displayNames.of('day'), 'string', 'day'); +assert.sameValue(typeof displayNames.of('dayPeriod'), 'string', 'dayPeriod'); +assert.sameValue(typeof displayNames.of('hour'), 'string', 'hour'); +assert.sameValue(typeof displayNames.of('minute'), 'string', 'minute'); +assert.sameValue(typeof displayNames.of('second'), 'string', 'second'); +assert.sameValue(typeof displayNames.of('timeZoneName'), 'string', 'timeZoneName'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-language-invalid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-language-invalid.js new file mode 100644 index 0000000000..e00ed3f1f5 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-language-invalid.js @@ -0,0 +1,90 @@ +// Copyright (C) 2023 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Throws a RangeError for invalid `language` codes +info: | + 12.3.3 Intl.DisplayNames.prototype.of ( code ) + + 1. If type is "language", then + a. If code cannot be matched by the unicode_language_id Unicode locale nonterminal, throw a RangeError exception. + b. If IsStructurallyValidLanguageTag(code) is false, throw a RangeError exception. + c. Return CanonicalizeUnicodeLocaleId(code). +features: [Intl.DisplayNames-v2] +---*/ + +var displayNames = new Intl.DisplayNames(undefined, {type: 'language'}); + +assert.throws(RangeError, function() { + displayNames.of(''); +}, 'invalid language subtag - empty string'); + +assert.throws(RangeError, function() { + displayNames.of('a'); +}, 'invalid language subtag - only one character'); + +assert.throws(RangeError, function() { + displayNames.of('abcdefghi'); +}, 'invalid language subtag - greater than 8 characters'); + +assert.throws(RangeError, function() { + displayNames.of('en-u-hebrew'); +}, 'singleton subtag'); + +assert.throws(RangeError, function() { + displayNames.of('aa-aaaa-bbbb'); +}, 'multiple script subtags'); + +assert.throws(RangeError, function() { + displayNames.of('aa-aaaaa-aaaaa'); +}, 'duplicate variant subtag'); + +assert.throws(RangeError, function() { + displayNames.of('aa-bb-cc'); +}, 'multiple region subtags'); + +assert.throws(RangeError, function() { + displayNames.of('1a'); +}, 'invalid language subtag - leading digit'); + +assert.throws(RangeError, function() { + displayNames.of('aa-1a'); +}, 'leading-digit subtag of length 2'); + +assert.throws(RangeError, function() { + displayNames.of('aa-1aa'); +}, 'leading-digit non-numeric subtag of length 3'); + +assert.throws(RangeError, function() { + displayNames.of('@#$%@#$'); +}, 'invalid characters'); + +assert.throws(RangeError, function() { + displayNames.of('en-US-'); +}, 'separator not followed by subtag'); + +assert.throws(RangeError, function() { + displayNames.of('-en'); +}, 'separator at start'); + +assert.throws(RangeError, function() { + displayNames.of('en--GB'); +}, 'missing subtag between separators'); + +assert.throws(RangeError, function() { + displayNames.of('root'); +}, 'BCP 47-incompatible CLDR syntax ("root" instead of "und")'); + +assert.throws(RangeError, function(){ + displayNames.of('abcd-GB'); +}, 'BCP 47-incompatible CLDR syntax (script subtag without a language subtag)'); + +assert.throws(RangeError, function(){ + displayNames.of('abcd'); +}, 'BCP 47-incompatible CLDR syntax (bare script subtag)'); + +assert.throws(RangeError, function(){ + displayNames.of('en_GB'); +}, 'BCP 47-incompatible CLDR syntax (_ as separator)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-language-valid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-language-valid.js new file mode 100644 index 0000000000..2b7932bf90 --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-language-valid.js @@ -0,0 +1,76 @@ +// Copyright (C) 2023 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Returns string value for valid `language` codes +features: [Intl.DisplayNames] +---*/ + + +/* +unicode_language_id = "root" // not allowed in ES + | (unicode_language_subtag + (sep unicode_script_subtag)? + | unicode_script_subtag) + (sep unicode_region_subtag)? + (sep unicode_variant_subtag)* + */ + +// unicode_language_subtag = alpha{2,3} | alpha{5,8} ; + +var languages = [ { subtag: 'ab', description: '2 letter language_subtag' }, + { subtag: 'cde', description: '3 letter language_subtag' }, + { subtag: 'zzzzzzzz', description: '8 letter language_subtag'} ]; + +// unicode_script_subtag = alpha{4} ; +var scripts = [ {subtag: 'abcd', description: '4 letter script_subtag' }, + {subtag: '', description: ''} ]; + +// unicode_region_subtag = (alpha{2} | digit{3}) ; +var regions = [ {subtag: 'ab', description: '2 letter region_subtag' }, + {subtag: '123', description: '3 digit region_subtag'}, + {subtag: '', description: ''} ]; + +// unicode_variant_subtag = (alphanum{5, 8} | digit alphanum{3} + +var variants = [ {subtag: 'abcde', description: '5 letter variant_subtag'}, + {subtag: 'fghijklm', description: '8 letter variant_subtag'}, + {subtag: '12345', description: '5 digit variant_subtag'}, + {subtag: '1nopq', description: '5 chararcter leading digit variant_subtag'}, + {subtag: '12345678', description: '8 digit variant_subtag'}, + {subtag: 'a2345678', description: '8 character trailing digit variant_subtag'}, + {subtag: '1abc', description: 'leading digit 4 character variant_subtag' }, + {subtag: '2345', description: '4 digit variant_subtag'}, + {subtag: '6d7e', description: 'leading digit 4 character mixed alphanum variant_subtag'}, + {subtag: '', description: ''} ]; + + +function notEmpty(subtag) { + return subtag !== ''; +} + +var displayNames = new Intl.DisplayNames(undefined, {type: 'language'}); + +for (var l in languages) { + for (var s in scripts) { + for (var r in regions) { + for (var v in variants) { + var languageTag = [languages[l].subtag, scripts[s].subtag, regions[r].subtag, variants[v].subtag].filter(notEmpty).join('-'); + var languageDescription = [languages[l].description, scripts[s].description, regions[r].description, variants[v].description].filter(notEmpty).join(', '); + + assert.sameValue(typeof displayNames.of(languageTag), 'string', languageDescription + ": " + languageTag); + if (variants[v].subtag !== ''){ + for (var vAdditional in variants){ + if (variants[vAdditional].subtag !== '' && vAdditional !== v){ + languageTag += '-' + variants[vAdditional].subtag; + languageDescription += ", " + variants[vAdditional].description; + assert.sameValue(typeof displayNames.of(languageTag), 'string', languageDescription + ": " + languageTag); + } + } + } + } + } + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js new file mode 100644 index 0000000000..0fcce4ac7e --- /dev/null +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js @@ -0,0 +1,85 @@ +// Copyright 2023 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-Intl.DisplayNames.prototype.of +description: Throws a RangeError for invalid `region` codes +info: | + 12.5.1 CanonicalCodeForDisplayNames ( code ) + + ... + 2. If type is "region", then + a. If code cannot be matched by the unicode_region_subtag Unicode locale nonterminal, throw a RangeError exception. + b. Return the ASCII-uppercase of code. +features: [Intl.DisplayNames] +---*/ + +// https://unicode.org/reports/tr35/#unicode_region_subtag +// unicode_region_subtag = (alpha{2} | digit{3}) ; + +var displayNames = new Intl.DisplayNames(undefined, {type: 'region'}); + +assert.throws(RangeError, function() { + displayNames.of('00'); +}, 'insufficient length, numeric'); + +assert.throws(RangeError, function() { + displayNames.of('a'); +}, 'insufficient length, alpha'); + +assert.throws(RangeError, function() { + displayNames.of('aaa'); +}, 'excessive length, alpha'); + +assert.throws(RangeError, function() { + displayNames.of('1111'); +}, 'excessive length, numeric'); + +assert.throws(RangeError, function() { + displayNames.of(''); +}, 'empty string'); + +assert.throws(RangeError, function() { + displayNames.of('a01'); +}, 'mixed alphanumeric (alpha first, length 3)'); + +assert.throws(RangeError, function() { + displayNames.of('a1'); +}, 'mixed alphanumeric (alpha first, length 2)'); + +assert.throws(RangeError, function() { + displayNames.of('1a'); +}, 'mixed alphanumeric (numeric first, length 2)'); + +assert.throws(RangeError, function() { + displayNames.of('1a1'); +}, 'mixed alphanumeric (numeric first, length 3)'); + +assert.throws(RangeError, function() { + displayNames.of('-111'); +}, 'leading separator (dash)'); + +assert.throws(RangeError, function() { + displayNames.of('_111'); +}, 'leading separator (underscore)'); + +assert.throws(RangeError, function() { + displayNames.of('111-'); +}, 'trailing separator (dash)'); + +assert.throws(RangeError, function() { + displayNames.of('111-'); +}, 'trailing separator (underscore)'); + +assert.throws(RangeError, function() { + displayNames.of(' aa'); +}, 'leading space'); + +assert.throws(RangeError, function() { + displayNames.of('aa '); +}, 'trailing space'); + +assert.throws(RangeError, function() { + displayNames.of('a c'); +}, 'interstitial space'); + +reportCompare(0, 0); |