| 1 |
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
// Slip from intl402/Locale/constructor-non-iana-canon.js |
| 5 |
/*--- |
| 6 |
esid: sec-intl.getcanonicallocales |
| 7 |
description: > |
| 8 |
Verifies canonicalization, of specific tags. |
| 9 |
info: | |
| 10 |
ApplyOptionsToTag( tag, options ) |
| 11 |
10. Return CanonicalizeLanguageTag(tag). |
| 12 |
---*/ |
| 13 |
|
| 14 |
// Test some language tags where we know that either CLDR or ICU produce |
| 15 |
// different results compared to the canonicalization specified in RFC 5646. |
| 16 |
var testData = [ |
| 17 |
{ |
| 18 |
tag: "mo", |
| 19 |
canonical: "ro", |
| 20 |
}, |
| 21 |
{ |
| 22 |
tag: "es-ES-preeuro", |
| 23 |
}, |
| 24 |
{ |
| 25 |
tag: "uz-UZ-cyrillic", |
| 26 |
}, |
| 27 |
{ |
| 28 |
tag: "posix", |
| 29 |
}, |
| 30 |
{ |
| 31 |
tag: "hi-direct", |
| 32 |
}, |
| 33 |
{ |
| 34 |
tag: "zh-pinyin", |
| 35 |
}, |
| 36 |
{ |
| 37 |
tag: "zh-stroke", |
| 38 |
}, |
| 39 |
{ |
| 40 |
tag: "aar-x-private", |
| 41 |
// "aar" should be canonicalized into "aa" because "aar" matches the type attribute of |
| 42 |
// a languageAlias element in |
| 43 |
// https://www.unicode.org/repos/cldr/trunk/common/supplemental/supplementalMetadata.xml |
| 44 |
canonical: "aa-x-private", |
| 45 |
}, |
| 46 |
{ |
| 47 |
tag: "heb-x-private", |
| 48 |
// "heb" should be canonicalized into "he" because "heb" matches the type attribute of |
| 49 |
// a languageAlias element in |
| 50 |
// https://www.unicode.org/repos/cldr/trunk/common/supplemental/supplementalMetadata.xml |
| 51 |
canonical: "he-x-private", |
| 52 |
}, |
| 53 |
{ |
| 54 |
tag: "de-u-kf", |
| 55 |
}, |
| 56 |
{ |
| 57 |
tag: "ces", |
| 58 |
// "ces" should be canonicalized into "cs" because "ces" matches the type attribute of |
| 59 |
// a languageAlias element in |
| 60 |
// https://www.unicode.org/repos/cldr/trunk/common/supplemental/supplementalMetadata.xml |
| 61 |
canonical: "cs", |
| 62 |
}, |
| 63 |
{ |
| 64 |
tag: "hy-arevela", |
| 65 |
canonical: "hy", |
| 66 |
}, |
| 67 |
{ |
| 68 |
tag: "hy-arevmda", |
| 69 |
canonical: "hyw", |
| 70 |
}, |
| 71 |
]; |
| 72 |
|
| 73 |
for (const {tag, canonical = tag} of testData) { |
| 74 |
assert.sameValue( |
| 75 |
Intl.getCanonicalLocales(tag)[0], |
| 76 |
canonical, |
| 77 |
'The value of Intl.getCanonicalLocales(tag)[0] equals the value of `canonical`' |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
reportCompare(0, 0); |