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 )
|
|
|
|
...
|
2019-01-24 18:34:03 +01:00
|
|
|
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
2018-05-11 10:33:32 +02:00
|
|
|
|
2019-01-24 18:34:03 +01:00
|
|
|
IsStructurallyValidLanguageTag ( locale )
|
2018-05-11 10:33:32 +02:00
|
|
|
|
2019-01-24 18:34:03 +01:00
|
|
|
The IsStructurallyValidLanguageTag abstract operation verifies that the
|
|
|
|
locale argument (which must be a String value)
|
|
|
|
|
|
|
|
represents a well-formed Unicode BCP 47 Locale Identifier" as specified in
|
|
|
|
Unicode Technical Standard 35 section 3.2, or successor,
|
2018-05-11 10:33:32 +02:00
|
|
|
|
|
|
|
features: [Intl.Locale]
|
|
|
|
---*/
|
|
|
|
|
|
|
|
const testData = [
|
2020-03-30 13:55:24 +02:00
|
|
|
// Regular grandfathered without modern replacement.
|
|
|
|
{
|
|
|
|
tag: "cel-gaulish",
|
|
|
|
options: {
|
|
|
|
language: "fr",
|
|
|
|
script: "Cyrl",
|
|
|
|
region: "FR",
|
|
|
|
numberingSystem: "latn",
|
|
|
|
},
|
2020-11-17 22:16:57 +01:00
|
|
|
canonical: "fr-Cyrl-FR-u-nu-latn",
|
2020-03-30 13:55:24 +02:00
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2019-01-24 18:34:03 +01:00
|
|
|
|
|
|
|
assert.throws(RangeError, () =>
|
|
|
|
new Intl.Locale("i-default",
|
|
|
|
{language: "fr", script: "Cyrl", region: "DE", numberingSystem: "latn"}
|
|
|
|
));
|
|
|
|
|
|
|
|
assert.throws(RangeError, () =>
|
|
|
|
new Intl.Locale("en-gb-oed",
|
|
|
|
{language: "fr", script: "Cyrl", region: "US", numberingSystem: "latn"}
|
|
|
|
));
|