mirror of https://github.com/tc39/test262.git
Improve and extend the tests for ApplyOptionsToTag.
This commit is contained in:
parent
40883f4c6a
commit
9300187c75
|
@ -15,15 +15,15 @@ info: |
|
||||||
|
|
||||||
ApplyOptionsToTag( tag, options )
|
ApplyOptionsToTag( tag, options )
|
||||||
...
|
...
|
||||||
9. If tag matches the langtag production, then
|
9. If tag matches neither the privateuse nor the grandfathered production, then
|
||||||
a. If language is not undefined, then
|
b. If language is not undefined, then
|
||||||
i. Set tag to tag with the substring corresponding to the language production replaced by the string language.
|
i. Set tag to tag with the substring corresponding to the language production replaced by the string language.
|
||||||
|
|
||||||
features: [Intl.Locale]
|
features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const validLanguageOptions = [
|
const validLanguageOptions = [
|
||||||
[undefined, "en"],
|
[undefined, undefined],
|
||||||
[null, "null"],
|
[null, "null"],
|
||||||
["zh-cmn", "cmn"],
|
["zh-cmn", "cmn"],
|
||||||
["ZH-CMN", "cmn"],
|
["ZH-CMN", "cmn"],
|
||||||
|
@ -38,7 +38,19 @@ for (const [language, expected] of validLanguageOptions) {
|
||||||
let options = { language };
|
let options = { language };
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en', options).toString(),
|
new Intl.Locale('en', options).toString(),
|
||||||
expected,
|
expected || 'en',
|
||||||
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
new Intl.Locale('en-US', options).toString(),
|
||||||
|
(expected || "en") + "-US",
|
||||||
|
`new Intl.Locale('en-US', options).toString() equals the value of ${expected}-US`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
new Intl.Locale('en-els', options).toString(),
|
||||||
|
expected || "en-els",
|
||||||
|
`new Intl.Locale('en-els', options).toString() equals the value of ${expected}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,19 @@ info: |
|
||||||
...
|
...
|
||||||
7. Let region be ? GetOption(options, "region", "string", undefined, undefined).
|
7. Let region be ? GetOption(options, "region", "string", undefined, undefined).
|
||||||
...
|
...
|
||||||
9. If tag matches the langtag production, then
|
9. If tag matches neither the privateuse nor the grandfathered production, then
|
||||||
...
|
...
|
||||||
c. If region is not undefined, then
|
d. If region is not undefined, then
|
||||||
i. If tag does not contain a region production, then
|
i. If tag does not contain a region production, then
|
||||||
1. Set tag to the concatenation of the language production of tag, the substring corresponding to the "-" script production if present, "-", region, and the rest of tag.
|
1. Set tag to the concatenation of the language production of tag, the substring corresponding to the "-" script production if present, "-", region, and the rest of tag.
|
||||||
|
ii. Else,
|
||||||
|
1. Set tag to tag with the substring corresponding to the region production replaced by the string region.
|
||||||
|
|
||||||
features: [Intl.Locale]
|
features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const validRegionOptions = [
|
const validRegionOptions = [
|
||||||
|
[undefined, undefined],
|
||||||
["FR", "en-FR"],
|
["FR", "en-FR"],
|
||||||
["554", "en-554"],
|
["554", "en-554"],
|
||||||
[554, "en-554"],
|
[554, "en-554"],
|
||||||
|
@ -35,12 +38,25 @@ for (const [region, expected] of validRegionOptions) {
|
||||||
let options = { region };
|
let options = { region };
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en', options).toString(),
|
new Intl.Locale('en', options).toString(),
|
||||||
expected,
|
expected || "en",
|
||||||
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale('en-US', options).toString(),
|
new Intl.Locale('en-US', options).toString(),
|
||||||
expected,
|
expected || "en-US",
|
||||||
`new Intl.Locale('en-US', options).toString() equals the value of ${expected}`
|
`new Intl.Locale('en-US', options).toString() equals the value of ${expected}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
new Intl.Locale('en-u-ca-gregory', options).toString(),
|
||||||
|
(expected || "en") + "-u-ca-gregory",
|
||||||
|
`new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expected}`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
new Intl.Locale('en-US-u-ca-gregory', options).toString(),
|
||||||
|
(expected || "en-US") + "-u-ca-gregory",
|
||||||
|
`new Intl.Locale('en-US-u-ca-gregory', options).toString() equals the value of ${expected}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ info: |
|
||||||
...
|
...
|
||||||
5. Let script be ? GetOption(options, "script", "string", undefined, undefined).
|
5. Let script be ? GetOption(options, "script", "string", undefined, undefined).
|
||||||
...
|
...
|
||||||
9. If tag matches the langtag production, then
|
9. If tag matches neither the privateuse nor the grandfathered production, then
|
||||||
...
|
...
|
||||||
b. If script is not undefined, then
|
c. If script is not undefined, then
|
||||||
i. If tag does not contain a script production, then
|
i. If tag does not contain a script production, then
|
||||||
1. Set tag to the concatenation of the language production of tag, "-", script, and the rest of tag.
|
1. Set tag to the concatenation of the language production of tag, "-", script, and the rest of tag.
|
||||||
ii. Else,
|
ii. Else,
|
||||||
|
@ -30,22 +30,30 @@ features: [Intl.Locale]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const validScriptOptions = [
|
const validScriptOptions = [
|
||||||
[null, "en-Null"],
|
[undefined, undefined],
|
||||||
["bali", "en-Bali"],
|
[null, "Null"],
|
||||||
["Bali", "en-Bali"],
|
["bali", "Bali"],
|
||||||
["bALI", "en-BALI"], // TODO REVIEW: is this the correct case regularization?
|
["Bali", "Bali"],
|
||||||
[{ toString() { return "Brai" } }, "en-Brai"],
|
["bALI", "BALI"], // TODO REVIEW: is this the correct case regularization?
|
||||||
|
[{ toString() { return "Brai" } }, "Brai"],
|
||||||
];
|
];
|
||||||
for (const [script, expected] of validScriptOptions) {
|
for (const [script, expected] of validScriptOptions) {
|
||||||
let options = { script };
|
let options = { script };
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale("en", options).toString(),
|
new Intl.Locale("en", options).toString(),
|
||||||
expected,
|
expected ? ("en-" + expected) : "en",
|
||||||
`new Intl.Locale("en", options).toString() equals the value of ${expected}`
|
`new Intl.Locale("en", options).toString() equals the value of ${expected}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
new Intl.Locale("en-DK", options).toString(),
|
||||||
|
(expected ? ("en-" + expected) : "en") + "-DK",
|
||||||
|
`new Intl.Locale("en", options).toString() equals the value of ${expected}`
|
||||||
|
);
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
new Intl.Locale("en-Cyrl", options).toString(),
|
new Intl.Locale("en-Cyrl", options).toString(),
|
||||||
expected,
|
expected ? ("en-" + expected) : "en-Cyrl",
|
||||||
`new Intl.Locale("en-Cyrl", options).toString() equals the value of ${expected}`
|
`new Intl.Locale("en-Cyrl", options).toString() equals the value of ${expected}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue