mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 05:55:36 +02:00
Remove unsupported irregular grandfathered tags. (#2029)
This commit is contained in:
parent
f39faeef87
commit
b7c9c6c78b
@ -13,26 +13,22 @@ info: |
|
|||||||
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
||||||
|
|
||||||
ApplyOptionsToTag( tag, options )
|
ApplyOptionsToTag( tag, options )
|
||||||
9. If tag matches neither the privateuse nor the grandfathered production, then
|
...
|
||||||
10. Return CanonicalizeLanguageTag(tag).
|
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]
|
features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const testData = [
|
const testData = [
|
||||||
// Irregular grandfathered tags.
|
// Canonicalized version of "en-GB-oed", which we can add "US" to right away.
|
||||||
|
|
||||||
// "en-GB-oed" is a grandfathered tag, so we can't add "US". After it is
|
|
||||||
// canonicalized to "en-GB-oxendict" we can append "US" and "u-ca-gregory".
|
|
||||||
{
|
|
||||||
tag: "en-GB-oed",
|
|
||||||
options: {
|
|
||||||
region: "US",
|
|
||||||
calendar: "gregory",
|
|
||||||
},
|
|
||||||
canonical: "en-US-oxendict-u-ca-gregory",
|
|
||||||
},
|
|
||||||
|
|
||||||
// Canonicalized version of the above, which we can add "US" to right away.
|
|
||||||
{
|
{
|
||||||
tag: "en-GB-oxendict",
|
tag: "en-GB-oxendict",
|
||||||
options: {
|
options: {
|
||||||
@ -41,50 +37,6 @@ const testData = [
|
|||||||
},
|
},
|
||||||
canonical: "en-US-oxendict-u-ca-gregory",
|
canonical: "en-US-oxendict-u-ca-gregory",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Regular grandfathered tags.
|
|
||||||
|
|
||||||
// "no-bok" is a grandfathered, so "NO"/"SE" isn't added. After
|
|
||||||
// canonicalization we can append "NO"/"SE" and "u-ca-gregory".
|
|
||||||
{
|
|
||||||
tag: "no-bok",
|
|
||||||
options: {
|
|
||||||
region: "NO",
|
|
||||||
calendar: "gregory",
|
|
||||||
},
|
|
||||||
canonical: "nb-NO-u-ca-gregory",
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
tag: "no-bok",
|
|
||||||
options: {
|
|
||||||
region: "SE",
|
|
||||||
calendar: "gregory",
|
|
||||||
},
|
|
||||||
canonical: "nb-SE-u-ca-gregory",
|
|
||||||
},
|
|
||||||
|
|
||||||
// "no-bok-NO" isn't a grandfathered tag, so we can replace "NO" with "SE"
|
|
||||||
// and can also append "u-ca-gregory".
|
|
||||||
{
|
|
||||||
tag: "no-bok-NO",
|
|
||||||
options: {
|
|
||||||
region: "SE",
|
|
||||||
calendar: "gregory",
|
|
||||||
},
|
|
||||||
canonical: "no-bok-SE-u-ca-gregory",
|
|
||||||
},
|
|
||||||
|
|
||||||
// "no-bok-SE" isn't a grandfathered tag, so we can replace "SE" with "NO"
|
|
||||||
// and can also append "u-ca-gregory".
|
|
||||||
{
|
|
||||||
tag: "no-bok-SE",
|
|
||||||
options: {
|
|
||||||
region: "NO",
|
|
||||||
calendar: "gregory",
|
|
||||||
},
|
|
||||||
canonical: "no-bok-NO-u-ca-gregory",
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const {tag, options, canonical} of testData) {
|
for (const {tag, options, canonical} of testData) {
|
||||||
@ -94,3 +46,13 @@ for (const {tag, options, canonical} of testData) {
|
|||||||
`new Intl.Locale("${tag}", ${options}).toString() returns "${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"}));
|
||||||
|
|
||||||
|
@ -7,57 +7,21 @@ description: >
|
|||||||
Verifies handling of options with grandfathered tags.
|
Verifies handling of options with grandfathered tags.
|
||||||
info: |
|
info: |
|
||||||
ApplyOptionsToTag( tag, options )
|
ApplyOptionsToTag( tag, options )
|
||||||
|
...
|
||||||
|
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
||||||
|
|
||||||
...
|
IsStructurallyValidLanguageTag ( locale )
|
||||||
9. If tag matches neither the privateuse nor the grandfathered production, then
|
|
||||||
...
|
|
||||||
|
|
||||||
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
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
|
||||||
2. If tag matches the privateuse or the grandfathered production, then
|
Unicode Technical Standard 35 section 3.2, or successor,
|
||||||
a. Let result be a new Record.
|
|
||||||
b. Repeat for each element key of relevantExtensionKeys in List order,
|
|
||||||
i. Set result.[[<key>]] to undefined.
|
|
||||||
c. Set result.[[locale]] to tag.
|
|
||||||
d. Return result.
|
|
||||||
...
|
|
||||||
7. Repeat for each element key of relevantExtensionKeys in List order,
|
|
||||||
e. Let optionsValue be options.[[<key>]].
|
|
||||||
f. If optionsValue is not undefined, then
|
|
||||||
ii. Let value be optionsValue.
|
|
||||||
iv. Else,
|
|
||||||
1. Append the Record{[[Key]]: key, [[Value]]: value} to keywords.
|
|
||||||
...
|
|
||||||
|
|
||||||
features: [Intl.Locale]
|
features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const testData = [
|
const testData = [
|
||||||
// Irregular grandfathered without modern replacement.
|
|
||||||
{
|
|
||||||
tag: "i-default",
|
|
||||||
options: {
|
|
||||||
language: "fr",
|
|
||||||
script: "Cyrl",
|
|
||||||
region: "DE",
|
|
||||||
numberingSystem: "latn",
|
|
||||||
},
|
|
||||||
canonical: "fr-Cyrl-DE-u-nu-latn",
|
|
||||||
},
|
|
||||||
|
|
||||||
// Irregular grandfathered with modern replacement.
|
|
||||||
{
|
|
||||||
tag: "en-gb-oed",
|
|
||||||
options: {
|
|
||||||
language: "fr",
|
|
||||||
script: "Cyrl",
|
|
||||||
region: "US",
|
|
||||||
numberingSystem: "latn",
|
|
||||||
},
|
|
||||||
canonical: "fr-Cyrl-US-oxendict-u-nu-latn",
|
|
||||||
},
|
|
||||||
|
|
||||||
// Regular grandfathered without modern replacement.
|
// Regular grandfathered without modern replacement.
|
||||||
{
|
{
|
||||||
tag: "cel-gaulish",
|
tag: "cel-gaulish",
|
||||||
@ -91,3 +55,13 @@ for (const {tag, options, canonical} of testData) {
|
|||||||
assert.sameValue(loc[name], value);
|
assert.sameValue(loc[name], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.throws(RangeError, () =>
|
||||||
|
new Intl.Locale("i-default",
|
||||||
|
{language: "fr", script: "Cyrl", region: "DE", numberingSystem: "latn"}
|
||||||
|
));
|
||||||
|
|
||||||
|
assert.throws(RangeError, () =>
|
||||||
|
new Intl.Locale("en-gb-oed",
|
||||||
|
{language: "fr", script: "Cyrl", region: "US", numberingSystem: "latn"}
|
||||||
|
));
|
||||||
|
@ -7,29 +7,24 @@ description: >
|
|||||||
Verifies getters with grandfathered tags.
|
Verifies getters with grandfathered tags.
|
||||||
info: |
|
info: |
|
||||||
get Intl.Locale.prototype.baseName
|
get Intl.Locale.prototype.baseName
|
||||||
4. If locale does not match the langtag production, return locale.
|
|
||||||
5. Return the substring of locale corresponding to the
|
5. Return the substring of locale corresponding to the
|
||||||
language ["-" script] ["-" region] *("-" variant)
|
language ["-" script] ["-" region] *("-" variant)
|
||||||
subsequence of the langtag grammar.
|
subsequence of the unicode_language_id grammar.
|
||||||
|
|
||||||
get Intl.Locale.prototype.language
|
get Intl.Locale.prototype.language
|
||||||
4. If locale matches the privateuse or the grandfathered production, return locale.
|
5. Return the substring of locale corresponding to the
|
||||||
|
unicode_language_subtag production.
|
||||||
|
|
||||||
get Intl.Locale.prototype.script
|
get Intl.Locale.prototype.script
|
||||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
6. Return the substring of locale corresponding to the
|
||||||
|
unicode_script_subtag production.
|
||||||
|
|
||||||
get Intl.Locale.prototype.region
|
get Intl.Locale.prototype.region
|
||||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
6. Return the substring of locale corresponding to the unicode_region_subtag
|
||||||
|
production.
|
||||||
features: [Intl.Locale]
|
features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// Irregular grandfathered language tag.
|
|
||||||
var loc = new Intl.Locale("i-default");
|
|
||||||
assert.sameValue(loc.baseName, "i-default"); // Step 4.
|
|
||||||
assert.sameValue(loc.language, "i-default");
|
|
||||||
assert.sameValue(loc.script, undefined);
|
|
||||||
assert.sameValue(loc.region, undefined);
|
|
||||||
|
|
||||||
// Regular grandfathered language tag.
|
// Regular grandfathered language tag.
|
||||||
var loc = new Intl.Locale("cel-gaulish");
|
var loc = new Intl.Locale("cel-gaulish");
|
||||||
assert.sameValue(loc.baseName, "cel-gaulish"); // Step 5.
|
assert.sameValue(loc.baseName, "cel-gaulish"); // Step 5.
|
||||||
@ -38,8 +33,7 @@ assert.sameValue(loc.script, undefined);
|
|||||||
assert.sameValue(loc.region, undefined);
|
assert.sameValue(loc.region, undefined);
|
||||||
|
|
||||||
// Regular grandfathered language tag.
|
// Regular grandfathered language tag.
|
||||||
var loc = new Intl.Locale("zh-min");
|
assert.throws(RangeError, () => new Intl.Locale("zh-min"));
|
||||||
assert.sameValue(loc.baseName, "zh-min"); // Step 5.
|
|
||||||
assert.sameValue(loc.language, "zh-min");
|
assert.throws(RangeError, () => new Intl.Locale("i-default"));
|
||||||
assert.sameValue(loc.script, undefined);
|
|
||||||
assert.sameValue(loc.region, undefined);
|
|
||||||
|
@ -7,7 +7,26 @@ description: >
|
|||||||
Verifies canonicalization, minimization and maximization of specific tags.
|
Verifies canonicalization, minimization and maximization of specific tags.
|
||||||
info: |
|
info: |
|
||||||
ApplyOptionsToTag( tag, options )
|
ApplyOptionsToTag( tag, options )
|
||||||
10. Return CanonicalizeLanguageTag(tag).
|
|
||||||
|
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
||||||
|
|
||||||
|
9. Set tag to CanonicalizeLanguageTag(tag).
|
||||||
|
|
||||||
|
CanonicalizeLanguageTag( tag )
|
||||||
|
|
||||||
|
The CanonicalizeLanguageTag abstract operation returns the canonical and
|
||||||
|
case-regularized form of the locale argument (which must be a String value
|
||||||
|
that is a structurally valid Unicode BCP 47 Locale Identifier as verified by
|
||||||
|
the IsStructurallyValidLanguageTag abstract operation).
|
||||||
|
|
||||||
|
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,
|
||||||
|
|
||||||
|
|
||||||
Intl.Locale.prototype.maximize ()
|
Intl.Locale.prototype.maximize ()
|
||||||
3. Let maximal be the result of the Add Likely Subtags algorithm applied to loc.[[Locale]].
|
3. Let maximal be the result of the Add Likely Subtags algorithm applied to loc.[[Locale]].
|
||||||
@ -18,94 +37,27 @@ features: [Intl.Locale]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
const irregularGrandfathered = [
|
const irregularGrandfathered = [
|
||||||
{
|
"en-GB-oed",
|
||||||
tag: "en-GB-oed",
|
"i-ami",
|
||||||
canonical: "en-GB-oxendict",
|
"i-bnn",
|
||||||
maximized: "en-Latn-GB-oxendict",
|
"i-default",
|
||||||
},
|
"i-enochian",
|
||||||
{
|
"i-hak",
|
||||||
tag: "i-ami",
|
"i-klingon",
|
||||||
canonical: "ami",
|
"i-lux",
|
||||||
},
|
"i-mingo",
|
||||||
{
|
"i-navajo",
|
||||||
tag: "i-bnn",
|
"i-pwn",
|
||||||
canonical: "bnn",
|
"i-tao",
|
||||||
},
|
"i-tay",
|
||||||
{
|
"i-tsu",
|
||||||
tag: "i-default",
|
"sgn-BE-FR",
|
||||||
canonical: "i-default",
|
"sgn-BE-NL",
|
||||||
},
|
"sgn-CH-DE",
|
||||||
{
|
|
||||||
tag: "i-enochian",
|
|
||||||
canonical: "i-enochian",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-hak",
|
|
||||||
canonical: "hak",
|
|
||||||
maximized: "hak-Hans-CN",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-klingon",
|
|
||||||
canonical: "tlh",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-lux",
|
|
||||||
canonical: "lb",
|
|
||||||
maximized: "lb-Latn-LU",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-mingo",
|
|
||||||
canonical: "i-mingo",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-navajo",
|
|
||||||
canonical: "nv",
|
|
||||||
maximized: "nv-Latn-US",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-pwn",
|
|
||||||
canonical: "pwn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-tao",
|
|
||||||
canonical: "tao",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-tay",
|
|
||||||
canonical: "tay",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "i-tsu",
|
|
||||||
canonical: "tsu",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "sgn-BE-FR",
|
|
||||||
canonical: "sfb",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "sgn-BE-NL",
|
|
||||||
canonical: "vgt",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "sgn-CH-DE",
|
|
||||||
canonical: "sgg",
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const {tag, canonical, maximized = canonical, minimized = canonical} of irregularGrandfathered) {
|
for (const tag of irregularGrandfathered) {
|
||||||
assert.sameValue(Intl.getCanonicalLocales(tag)[0], canonical);
|
assert.throws(RangeError, () => new Intl.Locale(tag));
|
||||||
|
|
||||||
const loc = new Intl.Locale(tag);
|
|
||||||
assert.sameValue(loc.toString(), canonical);
|
|
||||||
|
|
||||||
assert.sameValue(loc.maximize().toString(), maximized);
|
|
||||||
assert.sameValue(loc.maximize().maximize().toString(), maximized);
|
|
||||||
|
|
||||||
assert.sameValue(loc.minimize().toString(), minimized);
|
|
||||||
assert.sameValue(loc.minimize().minimize().toString(), minimized);
|
|
||||||
|
|
||||||
assert.sameValue(loc.maximize().minimize().toString(), minimized);
|
|
||||||
assert.sameValue(loc.minimize().maximize().toString(), maximized);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const regularGrandfathered = [
|
const regularGrandfathered = [
|
||||||
@ -118,16 +70,6 @@ const regularGrandfathered = [
|
|||||||
tag: "cel-gaulish",
|
tag: "cel-gaulish",
|
||||||
canonical: "cel-gaulish",
|
canonical: "cel-gaulish",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
tag: "no-bok",
|
|
||||||
canonical: "nb",
|
|
||||||
maximized: "nb-Latn-NO",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "no-nyn",
|
|
||||||
canonical: "nn",
|
|
||||||
maximized: "nn-Latn-NO",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
tag: "zh-guoyu",
|
tag: "zh-guoyu",
|
||||||
canonical: "cmn",
|
canonical: "cmn",
|
||||||
@ -137,15 +79,6 @@ const regularGrandfathered = [
|
|||||||
canonical: "hak",
|
canonical: "hak",
|
||||||
maximized: "hak-Hans-CN",
|
maximized: "hak-Hans-CN",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
tag: "zh-min",
|
|
||||||
canonical: "zh-min",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tag: "zh-min-nan",
|
|
||||||
canonical: "nan",
|
|
||||||
maximized: "nan-Hans-CN",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
tag: "zh-xiang",
|
tag: "zh-xiang",
|
||||||
canonical: "hsn",
|
canonical: "hsn",
|
||||||
@ -169,6 +102,17 @@ for (const {tag, canonical, maximized = canonical, minimized = canonical} of reg
|
|||||||
assert.sameValue(loc.minimize().maximize().toString(), maximized);
|
assert.sameValue(loc.minimize().maximize().toString(), maximized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const regularGrandfatheredWithExtLang = [
|
||||||
|
"no-bok",
|
||||||
|
"no-nyn",
|
||||||
|
"zh-min",
|
||||||
|
"zh-min-nan",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const tag of regularGrandfatheredWithExtLang) {
|
||||||
|
assert.throws(RangeError, () => new Intl.Locale(tag));
|
||||||
|
}
|
||||||
|
|
||||||
// Add constiants, extensions, and privateuse subtags to regular grandfathered
|
// Add constiants, extensions, and privateuse subtags to regular grandfathered
|
||||||
// language tags and ensure it produces the "expected" result.
|
// language tags and ensure it produces the "expected" result.
|
||||||
const extras = [
|
const extras = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user