mirror of https://github.com/tc39/test262.git
Various additions to the Intl.Locale test coverage.
This commit is contained in:
parent
92003a3e52
commit
501a9a674f
|
@ -183,6 +183,11 @@ function getInvalidLanguageTags() {
|
|||
"中文", // non-ASCII letters
|
||||
"en-ß", // non-ASCII letters
|
||||
"ıd", // non-ASCII letters
|
||||
"es-Latn-latn", // two scripts
|
||||
"pl-PL-pl", // two regions
|
||||
"u-ca-gregory", // extension in first place
|
||||
"de-1996-1996", // duplicate numeric variant
|
||||
"pt-u-ca-gregory-u-nu-latn", // duplicate singleton subtag
|
||||
|
||||
// underscores in different parts of the language tag
|
||||
"de_DE",
|
||||
|
|
|
@ -50,7 +50,8 @@ const invalidLanguageOptions = [
|
|||
"i-klingon",
|
||||
|
||||
// Regular grandfathered language tag.
|
||||
"zh-Hant",
|
||||
"zh-min",
|
||||
"zh-min-nan",
|
||||
|
||||
// Reserved with extended language subtag
|
||||
"abcd-US",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
|
@ -25,6 +25,13 @@ const invalidNumberingSystemOptions = [
|
|||
"ab",
|
||||
"abcdefghi",
|
||||
"abc-abcdefghi",
|
||||
"!invalid!",
|
||||
"-latn-",
|
||||
"latn-",
|
||||
"latn--",
|
||||
"latn-ca",
|
||||
"latn-ca-",
|
||||
"latn-ca-gregory",
|
||||
];
|
||||
for (const invalidNumberingSystemOption of invalidNumberingSystemOptions) {
|
||||
assert.throws(RangeError, function() {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Verifies canonicalization of specific tags.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
10. Return CanonicalizeLanguageTag(tag).
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validLanguageTags = {
|
||||
"eN": "en",
|
||||
"en-gb": "en-GB",
|
||||
"IT-LATN-iT": "it-Latn-IT",
|
||||
"ar-ma-u-ca-islamicc": "ar-MA-u-ca-islamicc",
|
||||
"th-th-u-nu-thai": "th-TH-u-nu-thai",
|
||||
"X-u-foo": "x-u-foo",
|
||||
"en-x-u-foo": "en-x-u-foo",
|
||||
"en-a-bar-x-u-foo": "en-a-bar-x-u-foo",
|
||||
"en-x-u-foo-a-bar": "en-x-u-foo-a-bar",
|
||||
"en-u-baz-a-bar-x-u-foo": "en-a-bar-u-baz-x-u-foo",
|
||||
"Flob": "flob",
|
||||
"ZORK": "zork",
|
||||
"Blah-latn": "blah-Latn",
|
||||
"QuuX-latn-us": "quux-Latn-US",
|
||||
"SPAM-gb-x-Sausages-BACON-eggs": "spam-GB-x-sausages-bacon-eggs",
|
||||
"DE-1996": "de-1996",
|
||||
"sl-ROZAJ-BISKE-1994": "sl-rozaj-biske-1994",
|
||||
"zh-latn-pinyin-pinyin2": "zh-Latn-pinyin-pinyin2",
|
||||
};
|
||||
|
||||
for (const [langtag, canonical] of Object.entries(validLanguageTags)) {
|
||||
assert.sameValue(new Intl.Locale(canonical).toString(), canonical,
|
||||
`"${canonical}" should pass through unchanged`);
|
||||
assert.sameValue(new Intl.Locale(langtag).toString(), canonical,
|
||||
`"${langtag}" should be canonicalized to "${canonical}`);
|
||||
}
|
Loading…
Reference in New Issue