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: >
|
2018-10-03 16:24:38 +02:00
|
|
|
Verifies the handling of options with grandfathered tags.
|
2018-05-11 10:33:32 +02:00
|
|
|
info: |
|
2018-10-03 16:24:38 +02:00
|
|
|
Intl.Locale( tag [, options] )
|
|
|
|
12. Set tag to ? ApplyOptionsToTag(tag, options).
|
|
|
|
14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
|
|
|
|
16. Set opt.[[ca]] to calendar.
|
|
|
|
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
2018-05-11 10:33:32 +02:00
|
|
|
|
2018-10-03 16:24:38 +02:00
|
|
|
ApplyOptionsToTag( tag, options )
|
2019-01-24 18:34:03 +01:00
|
|
|
...
|
|
|
|
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
|
|
|
|
|
|
|
IsStructurallyValidLanguageTag ( locale )
|
|
|
|
|
|
|
|
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 = [
|
2019-01-24 18:34:03 +01:00
|
|
|
// Canonicalized version of "en-GB-oed", which we can add "US" to right away.
|
2018-10-03 16:24:38 +02:00
|
|
|
{
|
|
|
|
tag: "en-GB-oxendict",
|
|
|
|
options: {
|
|
|
|
region: "US",
|
|
|
|
calendar: "gregory",
|
2018-05-11 10:33:32 +02:00
|
|
|
},
|
2018-10-03 16:24:38 +02:00
|
|
|
canonical: "en-US-oxendict-u-ca-gregory",
|
|
|
|
},
|
2018-05-11 10:33:32 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
for (const {tag, options, canonical} of testData) {
|
2018-10-03 16:24:38 +02:00
|
|
|
assert.sameValue(
|
|
|
|
new Intl.Locale(tag, options).toString(),
|
|
|
|
canonical,
|
|
|
|
`new Intl.Locale("${tag}", ${options}).toString() returns "${canonical}"`
|
|
|
|
);
|
2018-05-11 10:33:32 +02:00
|
|
|
}
|
2019-01-24 18:34:03 +01:00
|
|
|
|
|
|
|
assert.throws(RangeError, () =>
|
|
|
|
new Intl.Locale("no-bok", {region: "NO", calendar: "gregory"}));
|
|
|
|
assert.throws(RangeError, () =>
|
|
|
|
new Intl.Locale("no-bok", {region: "SE", calendar: "gregory"}));
|
|
|
|
assert.throws(RangeError, () =>
|
|
|
|
new Intl.Locale("no-bok-NO", {region: "SE", calendar: "gregory"}));
|
|
|
|
assert.throws(RangeError, () =>
|
|
|
|
new Intl.Locale("no-bok-SE", {region: "NO", calendar: "gregory"}));
|
|
|
|
|