Debian Codegraph @

js/src/tests/test262/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js

raw
1 // Copyright (C) 2017 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-intl.getcanonicallocales
6 description: >
7 Call Intl.getCanonicalLocales function with grandfathered language tags.
8 info: |
9 8.2.1 Intl.getCanonicalLocales (locales)
10 1. Let ll be ? CanonicalizeLocaleList(locales).
11 2. Return CreateArrayFromList(ll).
12
13 9.2.1 CanonicalizeLocaleList (locales)
14 ...
15 7. Repeat, while k < len
16 ...
17 c. If kPresent is true, then
18 ...
19 v. Let canonicalizedTag be CanonicalizeLanguageTag(tag).
20 ...
21
22 6.2.3 CanonicalizeLanguageTag ( locale )
23 The CanonicalizeLanguageTag abstract operation returns the canonical and case-regularized form
24 of the locale argument (which must be a String value that is a structurally valid Unicode
25 BCP 47 Locale Identifier as verified by the IsStructurallyValidLanguageTag abstract operation).
26 A conforming implementation shall take the steps specified in the “BCP 47 Language Tag to
27 Unicode BCP 47 Locale Identifier” algorithm, from Unicode Technical Standard #35 LDML
28 § 3.3.1 BCP 47 Language Tag Conversion.
29
30 includes: [testIntl.js]
31 ---*/
32
33 // Generated from http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
34 // File-Date: 2017-08-15
35
36 var irregularGrandfathered = [
37 "en-gb-oed",
38 "i-ami",
39 "i-bnn",
40 "i-default",
41 "i-enochian",
42 "i-hak",
43 "i-klingon",
44 "i-lux",
45 "i-mingo",
46 "i-navajo",
47 "i-pwn",
48 "i-tao",
49 "i-tay",
50 "i-tsu",
51 "sgn-be-fr",
52 "sgn-be-nl",
53 "sgn-ch-de",
54 ];
55
56 var regularGrandfatheredNonUTS35 = [
57 "no-bok",
58 "no-nyn",
59 "zh-min",
60 "zh-min-nan",
61 ];
62
63 var regularGrandfatheredUTS35 = {
64 "art-lojban": "jbo",
65 "cel-gaulish": "xtg",
66 "zh-guoyu": "zh",
67 "zh-hakka": "hak",
68 "zh-xiang": "hsn",
69 };
70
71 // make sure the data above is correct
72 irregularGrandfathered.forEach(function (tag) {
73 assert.sameValue(
74 isCanonicalizedStructurallyValidLanguageTag(tag), false,
75 "Test data \"" + tag + "\" is not a structurally valid language tag."
76 );
77 });
78 regularGrandfatheredNonUTS35.forEach(function (tag) {
79 assert.sameValue(
80 isCanonicalizedStructurallyValidLanguageTag(tag), false,
81 "Test data \"" + tag + "\" is not a structurally valid language tag."
82 );
83 });
84 Object.getOwnPropertyNames(regularGrandfatheredUTS35).forEach(function (tag) {
85 var canonicalizedTag = regularGrandfatheredUTS35[tag];
86 assert(
87 isCanonicalizedStructurallyValidLanguageTag(canonicalizedTag),
88 "Test data \"" + canonicalizedTag + "\" is a canonicalized and structurally valid language tag."
89 );
90 });
91
92 Object.getOwnPropertyNames(regularGrandfatheredUTS35).forEach(function (tag) {
93 var canonicalLocales = Intl.getCanonicalLocales(tag);
94 assert.sameValue(canonicalLocales.length, 1);
95 assert.sameValue(canonicalLocales[0], regularGrandfatheredUTS35[tag]);
96 });
97
98 reportCompare(0, 0);