test262/test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js

97 lines
2.8 KiB
JavaScript
Raw Normal View History

// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.getcanonicallocales
description: >
Call Intl.getCanonicalLocales function with grandfathered language tags.
info: |
8.2.1 Intl.getCanonicalLocales (locales)
1. Let ll be ? CanonicalizeLocaleList(locales).
2. Return CreateArrayFromList(ll).
9.2.1 CanonicalizeLocaleList (locales)
...
7. Repeat, while k < len
...
c. If kPresent is true, then
...
v. Let canonicalizedTag be CanonicalizeLanguageTag(tag).
...
6.2.3 CanonicalizeLanguageTag ( locale )
Update tests to parse language tags as Unicode BCP 47 Locale Identifiers harness/testIntl.js - Add now invalid tags to getInvalidLanguageTags, these tags were previously used in test files changed in this commit. - Update isCanonicalizedStructurallyValidLanguageTag regular expressions. test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js - Moved five now invalid tags to getInvalidLanguageTags function in testIntl.js test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js - All irregular grandfathered tags are invalid now - Regular grandfathered with extlang subtags are now also invalid - Regular grandfathered with variant-like subtags are still valid test/intl402/Intl/getCanonicalLocales/weird-cases.js - Revert changes from last commit - "x-u-foo" is now invalid and was moved to getInvalidLanguageTags function test/intl402/ListFormat/constructor/constructor/locales-valid.js test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js test/intl402/Segmenter/constructor/constructor/locales-valid.js - Irregular grandfathered and privateuse only are no longer valid language tags test/intl402/language-tags-canonicalized.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js test/intl402/language-tags-invalid.js - Invalid tags list in this file was a subset of getInvalidLanguageTags, so replaced with getInvalidLanguageTags to get more coverage test/intl402/language-tags-valid.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js
2019-03-11 18:33:40 +01:00
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).
A conforming implementation shall take the steps specified in the BCP 47 Language Tag to
Unicode BCP 47 Locale Identifier algorithm, from Unicode Technical Standard #35 LDML
§ 3.3.1 BCP 47 Language Tag Conversion.
includes: [testIntl.js]
---*/
// Generated from http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
// File-Date: 2017-08-15
Update tests to parse language tags as Unicode BCP 47 Locale Identifiers harness/testIntl.js - Add now invalid tags to getInvalidLanguageTags, these tags were previously used in test files changed in this commit. - Update isCanonicalizedStructurallyValidLanguageTag regular expressions. test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js - Moved five now invalid tags to getInvalidLanguageTags function in testIntl.js test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js - All irregular grandfathered tags are invalid now - Regular grandfathered with extlang subtags are now also invalid - Regular grandfathered with variant-like subtags are still valid test/intl402/Intl/getCanonicalLocales/weird-cases.js - Revert changes from last commit - "x-u-foo" is now invalid and was moved to getInvalidLanguageTags function test/intl402/ListFormat/constructor/constructor/locales-valid.js test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js test/intl402/Segmenter/constructor/constructor/locales-valid.js - Irregular grandfathered and privateuse only are no longer valid language tags test/intl402/language-tags-canonicalized.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js test/intl402/language-tags-invalid.js - Invalid tags list in this file was a subset of getInvalidLanguageTags, so replaced with getInvalidLanguageTags to get more coverage test/intl402/language-tags-valid.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js
2019-03-11 18:33:40 +01:00
var irregularGrandfathered = [
"en-gb-oed",
"i-ami",
"i-bnn",
"i-default",
"i-enochian",
"i-hak",
"i-klingon",
"i-lux",
"i-mingo",
"i-navajo",
"i-pwn",
"i-tao",
"i-tay",
"i-tsu",
"sgn-be-fr",
"sgn-be-nl",
"sgn-ch-de",
];
var regularGrandfatheredNonUTS35 = [
"no-bok",
"no-nyn",
"zh-min",
"zh-min-nan",
];
var regularGrandfatheredUTS35 = {
"art-lojban": "jbo",
"cel-gaulish": "xtg-x-cel-gaulish",
"zh-guoyu": "zh",
"zh-hakka": "hak",
"zh-xiang": "hsn",
};
// make sure the data above is correct
Update tests to parse language tags as Unicode BCP 47 Locale Identifiers harness/testIntl.js - Add now invalid tags to getInvalidLanguageTags, these tags were previously used in test files changed in this commit. - Update isCanonicalizedStructurallyValidLanguageTag regular expressions. test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js - Moved five now invalid tags to getInvalidLanguageTags function in testIntl.js test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js - All irregular grandfathered tags are invalid now - Regular grandfathered with extlang subtags are now also invalid - Regular grandfathered with variant-like subtags are still valid test/intl402/Intl/getCanonicalLocales/weird-cases.js - Revert changes from last commit - "x-u-foo" is now invalid and was moved to getInvalidLanguageTags function test/intl402/ListFormat/constructor/constructor/locales-valid.js test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js test/intl402/Segmenter/constructor/constructor/locales-valid.js - Irregular grandfathered and privateuse only are no longer valid language tags test/intl402/language-tags-canonicalized.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js test/intl402/language-tags-invalid.js - Invalid tags list in this file was a subset of getInvalidLanguageTags, so replaced with getInvalidLanguageTags to get more coverage test/intl402/language-tags-valid.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js
2019-03-11 18:33:40 +01:00
irregularGrandfathered.forEach(function (tag) {
assert.sameValue(
isCanonicalizedStructurallyValidLanguageTag(tag), false,
"Test data \"" + tag + "\" is not a structurally valid language tag."
);
});
regularGrandfatheredNonUTS35.forEach(function (tag) {
assert.sameValue(
isCanonicalizedStructurallyValidLanguageTag(tag), false,
"Test data \"" + tag + "\" is not a structurally valid language tag."
);
});
Object.getOwnPropertyNames(regularGrandfatheredUTS35).forEach(function (tag) {
var canonicalizedTag = regularGrandfatheredUTS35[tag];
assert(
isCanonicalizedStructurallyValidLanguageTag(canonicalizedTag),
Update tests to parse language tags as Unicode BCP 47 Locale Identifiers harness/testIntl.js - Add now invalid tags to getInvalidLanguageTags, these tags were previously used in test files changed in this commit. - Update isCanonicalizedStructurallyValidLanguageTag regular expressions. test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js - Moved five now invalid tags to getInvalidLanguageTags function in testIntl.js test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js - All irregular grandfathered tags are invalid now - Regular grandfathered with extlang subtags are now also invalid - Regular grandfathered with variant-like subtags are still valid test/intl402/Intl/getCanonicalLocales/weird-cases.js - Revert changes from last commit - "x-u-foo" is now invalid and was moved to getInvalidLanguageTags function test/intl402/ListFormat/constructor/constructor/locales-valid.js test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js test/intl402/Segmenter/constructor/constructor/locales-valid.js - Irregular grandfathered and privateuse only are no longer valid language tags test/intl402/language-tags-canonicalized.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js test/intl402/language-tags-invalid.js - Invalid tags list in this file was a subset of getInvalidLanguageTags, so replaced with getInvalidLanguageTags to get more coverage test/intl402/language-tags-valid.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js
2019-03-11 18:33:40 +01:00
"Test data \"" + canonicalizedTag + "\" is a canonicalized and structurally valid language tag."
);
});
Update tests to parse language tags as Unicode BCP 47 Locale Identifiers harness/testIntl.js - Add now invalid tags to getInvalidLanguageTags, these tags were previously used in test files changed in this commit. - Update isCanonicalizedStructurallyValidLanguageTag regular expressions. test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js - Moved five now invalid tags to getInvalidLanguageTags function in testIntl.js test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js - All irregular grandfathered tags are invalid now - Regular grandfathered with extlang subtags are now also invalid - Regular grandfathered with variant-like subtags are still valid test/intl402/Intl/getCanonicalLocales/weird-cases.js - Revert changes from last commit - "x-u-foo" is now invalid and was moved to getInvalidLanguageTags function test/intl402/ListFormat/constructor/constructor/locales-valid.js test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js test/intl402/Segmenter/constructor/constructor/locales-valid.js - Irregular grandfathered and privateuse only are no longer valid language tags test/intl402/language-tags-canonicalized.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js test/intl402/language-tags-invalid.js - Invalid tags list in this file was a subset of getInvalidLanguageTags, so replaced with getInvalidLanguageTags to get more coverage test/intl402/language-tags-valid.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js
2019-03-11 18:33:40 +01:00
Object.getOwnPropertyNames(regularGrandfatheredUTS35).forEach(function (tag) {
var canonicalLocales = Intl.getCanonicalLocales(tag);
assert.sameValue(canonicalLocales.length, 1);
Update tests to parse language tags as Unicode BCP 47 Locale Identifiers harness/testIntl.js - Add now invalid tags to getInvalidLanguageTags, these tags were previously used in test files changed in this commit. - Update isCanonicalizedStructurallyValidLanguageTag regular expressions. test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js - Moved five now invalid tags to getInvalidLanguageTags function in testIntl.js test/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js - All irregular grandfathered tags are invalid now - Regular grandfathered with extlang subtags are now also invalid - Regular grandfathered with variant-like subtags are still valid test/intl402/Intl/getCanonicalLocales/weird-cases.js - Revert changes from last commit - "x-u-foo" is now invalid and was moved to getInvalidLanguageTags function test/intl402/ListFormat/constructor/constructor/locales-valid.js test/intl402/RelativeTimeFormat/constructor/constructor/locales-valid.js test/intl402/Segmenter/constructor/constructor/locales-valid.js - Irregular grandfathered and privateuse only are no longer valid language tags test/intl402/language-tags-canonicalized.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js test/intl402/language-tags-invalid.js - Invalid tags list in this file was a subset of getInvalidLanguageTags, so replaced with getInvalidLanguageTags to get more coverage test/intl402/language-tags-valid.js - Same changes as in test/intl402/Intl/getCanonicalLocales/canonicalized-tags.js
2019-03-11 18:33:40 +01:00
assert.sameValue(canonicalLocales[0], regularGrandfatheredUTS35[tag]);
});