Remove test of extlang and 4 letter language (#2030)

This is due to the fact we now only accept Unicode Locale Identifier in
UTS 35.
This commit is contained in:
Frank Yung-Fong Tang 2019-01-24 09:23:30 -08:00 committed by Leo Balter
parent 9fccd9852e
commit 00d280d231
2 changed files with 31 additions and 18 deletions

View File

@ -13,10 +13,17 @@ info: |
12. Set tag to ? ApplyOptionsToTag(tag, options). 12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options ) ApplyOptionsToTag( tag, options )
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
... ...
9. If tag matches neither the privateuse nor the grandfathered production, then
b. If language is not undefined, then IsStructurallyValidLanguageTag ( locale )
i. Set tag to tag with the substring corresponding to the language production replaced by the string language.
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]
---*/ ---*/
@ -33,8 +40,4 @@ assert.sameValue(
`new Intl.Locale('en-US', {language: undefined}).toString() returns "en-US"` `new Intl.Locale('en-US', {language: undefined}).toString() returns "en-US"`
); );
assert.sameValue( assert.throws(RangeError, () => new Intl.Locale('en-els', {language: undefined}));
new Intl.Locale('en-els', {language: undefined}).toString(),
'en-els',
`new Intl.Locale('en-els', {language: undefined}).toString() returns "en-els"`
);

View File

@ -14,9 +14,15 @@ info: |
ApplyOptionsToTag( tag, options ) ApplyOptionsToTag( tag, options )
... ...
9. If tag matches neither the privateuse nor the grandfathered production, then 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
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. 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]
---*/ ---*/
@ -25,7 +31,6 @@ const validLanguageOptions = [
[null, 'null'], [null, 'null'],
['zh-cmn', 'cmn'], ['zh-cmn', 'cmn'],
['ZH-CMN', 'cmn'], ['ZH-CMN', 'cmn'],
['abcd', 'abcd'],
[{ toString() { return 'de' } }, 'de'], [{ toString() { return 'de' } }, 'de'],
]; ];
for (const [language, expected] of validLanguageOptions) { for (const [language, expected] of validLanguageOptions) {
@ -44,10 +49,15 @@ for (const [language, expected] of validLanguageOptions) {
`new Intl.Locale('en-US', {language: "${language}"}).toString() returns "${expect}"` `new Intl.Locale('en-US', {language: "${language}"}).toString() returns "${expect}"`
); );
expect = expected || 'en-els'; assert.throws(RangeError, () => new Intl.Locale('en-els', {language}));
assert.sameValue(
new Intl.Locale('en-els', {language}).toString(), }
expect,
`new Intl.Locale('en-els', {language: "${language}"}).toString() returns "${expect}"` const invalidLanguageOptions = [
); 'abcd',
];
for (const language of invalidLanguageOptions) {
assert.throws(RangeError, () => new Intl.Locale('en', {language}));
assert.throws(RangeError, () => new Intl.Locale('en-US', {language}));
assert.throws(RangeError, () => new Intl.Locale('en-els', {language}));
} }