summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Intl/getCanonicalLocales/preferred-grandfathered.js
blob: 51a536bbfc58ac159d17c3dc6ed42323479ab779 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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 )
    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

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",
  "zh-guoyu": "zh",
  "zh-hakka": "hak",
  "zh-xiang": "hsn",
};

// make sure the data above is correct
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),
    "Test data \"" + canonicalizedTag + "\" is a canonicalized and structurally valid language tag."
  );
});

Object.getOwnPropertyNames(regularGrandfatheredUTS35).forEach(function (tag) {
  var canonicalLocales = Intl.getCanonicalLocales(tag);
  assert.sameValue(canonicalLocales.length, 1);
  assert.sameValue(canonicalLocales[0], regularGrandfatheredUTS35[tag]);
});

reportCompare(0, 0);