-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created test for invalid region tags
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
test/intl402/DisplayNames/prototype/of/type-region-invalid.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// 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.3.3 Intl.DisplayNames.prototype.of ( 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] | ||
---*/ | ||
|
||
var displayNames = new Intl.DisplayNames(undefined, {type: 'region'}); | ||
|
||
assert.throws(RangeError, function() { | ||
displayNames.of('00'); | ||
}, 'insufficient length, digit'); | ||
|
||
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, digit'); | ||
|
||
assert.throws(RangeError, function() { | ||
displayNames.of(''); | ||
}, 'empty string'); | ||
|
||
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'); |