2018-05-11 10:33:32 +02:00
|
|
|
// 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 handling of options with grandfathered tags.
|
|
|
|
info: |
|
|
|
|
ApplyOptionsToTag( tag, options )
|
|
|
|
|
|
|
|
...
|
|
|
|
9. If tag matches neither the privateuse nor the grandfathered production, then
|
|
|
|
...
|
|
|
|
|
|
|
|
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
|
|
|
|
|
|
|
...
|
|
|
|
2. If tag matches the privateuse or the grandfathered production, then
|
|
|
|
a. Let result be a new Record.
|
|
|
|
b. Repeat for each element key of relevantExtensionKeys in List order,
|
|
|
|
i. Set result.[[<key>]] to undefined.
|
|
|
|
c. Set result.[[locale]] to tag.
|
|
|
|
d. Return result.
|
|
|
|
...
|
|
|
|
7. Repeat for each element key of relevantExtensionKeys in List order,
|
|
|
|
e. Let optionsValue be options.[[<key>]].
|
|
|
|
f. If optionsValue is not undefined, then
|
|
|
|
ii. Let value be optionsValue.
|
|
|
|
iv. Else,
|
|
|
|
1. Append the Record{[[Key]]: key, [[Value]]: value} to keywords.
|
|
|
|
...
|
|
|
|
|
|
|
|
features: [Intl.Locale]
|
|
|
|
---*/
|
|
|
|
|
|
|
|
const testData = [
|
|
|
|
// Irregular grandfathered without modern replacement.
|
|
|
|
{
|
|
|
|
tag: "i-default",
|
|
|
|
options: {
|
|
|
|
language: "fr",
|
|
|
|
script: "Cyrl",
|
|
|
|
region: "DE",
|
|
|
|
numberingSystem: "latn",
|
|
|
|
},
|
2018-10-17 16:45:33 +02:00
|
|
|
canonical: "fr-Cyrl-DE-u-nu-latn",
|
2018-05-11 10:33:32 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Irregular grandfathered with modern replacement.
|
|
|
|
{
|
|
|
|
tag: "en-gb-oed",
|
|
|
|
options: {
|
|
|
|
language: "fr",
|
|
|
|
script: "Cyrl",
|
|
|
|
region: "US",
|
|
|
|
numberingSystem: "latn",
|
|
|
|
},
|
2018-10-17 16:45:33 +02:00
|
|
|
canonical: "fr-Cyrl-US-oxendict-u-nu-latn",
|
2018-05-11 10:33:32 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Regular grandfathered without modern replacement.
|
|
|
|
{
|
|
|
|
tag: "cel-gaulish",
|
|
|
|
options: {
|
|
|
|
language: "fr",
|
|
|
|
script: "Cyrl",
|
|
|
|
region: "FR",
|
|
|
|
numberingSystem: "latn",
|
|
|
|
},
|
2018-10-17 16:45:33 +02:00
|
|
|
canonical: "fr-Cyrl-FR-u-nu-latn",
|
2018-05-11 10:33:32 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Regular grandfathered with modern replacement.
|
|
|
|
{
|
|
|
|
tag: "art-lojban",
|
|
|
|
options: {
|
|
|
|
language: "fr",
|
|
|
|
script: "Cyrl",
|
|
|
|
region: "ZZ",
|
|
|
|
numberingSystem: "latn",
|
|
|
|
},
|
2018-10-17 16:45:33 +02:00
|
|
|
canonical: "fr-Cyrl-ZZ-u-nu-latn",
|
2018-05-11 10:33:32 +02:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2018-10-17 16:45:33 +02:00
|
|
|
for (const {tag, options, canonical} of testData) {
|
2018-05-11 10:33:32 +02:00
|
|
|
const loc = new Intl.Locale(tag, options);
|
|
|
|
assert.sameValue(loc.toString(), canonical);
|
|
|
|
|
2018-10-17 16:45:33 +02:00
|
|
|
for (const [name, value] of Object.entries(options)) {
|
2018-05-11 10:33:32 +02:00
|
|
|
assert.sameValue(loc[name], value);
|
|
|
|
}
|
|
|
|
}
|