mirror of https://github.com/tc39/test262.git
Merge pull request #1553 from Ms2ger/Locale
Add some more Locale tests.
This commit is contained in:
commit
ef1d3a4eb6
|
@ -0,0 +1,125 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the order of evaluations of arguments and options for the Locale
|
||||
constructor.
|
||||
features: [Intl.Locale]
|
||||
includes: [compareArray.js]
|
||||
---*/
|
||||
|
||||
const order = [];
|
||||
new Intl.Locale(
|
||||
{ toString() { order.push("tag toString"); return "en"; } },
|
||||
{
|
||||
get language() {
|
||||
order.push("get language");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString language");
|
||||
return "de";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get script() {
|
||||
order.push("get script");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString script");
|
||||
return "Latn";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get region() {
|
||||
order.push("get region");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString region");
|
||||
return "DE";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get calendar() {
|
||||
order.push("get calendar");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString calendar");
|
||||
return "gregory";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get collation() {
|
||||
order.push("get collation");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString collation");
|
||||
return "zhuyin";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get hourCycle() {
|
||||
order.push("get hourCycle");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString hourCycle");
|
||||
return "h24";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get caseFirst() {
|
||||
order.push("get caseFirst");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString caseFirst");
|
||||
return "upper";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get numeric() {
|
||||
order.push("get numeric");
|
||||
return false;
|
||||
},
|
||||
|
||||
get numberingSystem() {
|
||||
order.push("get numberingSystem");
|
||||
return {
|
||||
toString() {
|
||||
order.push("toString numberingSystem");
|
||||
return "latn";
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const expected_order = [
|
||||
"tag toString",
|
||||
"get language",
|
||||
"toString language",
|
||||
"get script",
|
||||
"toString script",
|
||||
"get region",
|
||||
"toString region",
|
||||
"get calendar",
|
||||
"toString calendar",
|
||||
"get collation",
|
||||
"toString collation",
|
||||
"get hourCycle",
|
||||
"toString hourCycle",
|
||||
"get caseFirst",
|
||||
"toString caseFirst",
|
||||
"get numeric",
|
||||
"get numberingSystem",
|
||||
"toString numberingSystem"
|
||||
];
|
||||
|
||||
assert.compareArray(order, expected_order);
|
|
@ -0,0 +1,29 @@
|
|||
// 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 canonicalization of specific tags.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
10. Return CanonicalizeLanguageTag(tag).
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
// Pass Intl.Locale object and replace subtag.
|
||||
const enUS = new Intl.Locale("en-US");
|
||||
const enGB = new Intl.Locale(enUS, {region: "GB"});
|
||||
|
||||
assert.sameValue(enUS.toString(), "en-US");
|
||||
assert.sameValue(enGB.toString(), "en-GB");
|
||||
|
||||
// Pass Intl.Locale object and replace Unicode extension keyword.
|
||||
const zhUnihan = new Intl.Locale("zh-u-co-unihan");
|
||||
const zhZhuyin = new Intl.Locale(zhUnihan, {collation: "zhuyin"});
|
||||
|
||||
assert.sameValue(zhUnihan.toString(), "zh-u-co-unihan");
|
||||
assert.sameValue(zhZhuyin.toString(), "zh-u-co-zhuyin");
|
||||
|
||||
assert.sameValue(zhUnihan.collation, "unihan");
|
||||
assert.sameValue(zhZhuyin.collation, "zhuyin");
|
|
@ -0,0 +1,90 @@
|
|||
// 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 canonicalization, minimization and maximization of specific tags.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
10. Return CanonicalizeLanguageTag(tag).
|
||||
|
||||
Intl.Locale.prototype.maximize ()
|
||||
3. Let maximal be the result of the Add Likely Subtags algorithm applied to loc.[[Locale]].
|
||||
|
||||
Intl.Locale.prototype.minimize ()
|
||||
3. Let minimal be the result of the Remove Likely Subtags algorithm applied to loc.[[Locale]].
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
// Test some language tags where we know that either CLDR or ICU produce
|
||||
// different results compared to the canonicalization specified in RFC 5646.
|
||||
var testData = [
|
||||
{
|
||||
tag: "mo",
|
||||
canonical: "ro",
|
||||
maximized: "ro-Latn-RO",
|
||||
},
|
||||
{
|
||||
tag: "es-ES-preeuro",
|
||||
maximized: "es-Latn-ES-preeuro",
|
||||
minimized: "es-preeuro",
|
||||
},
|
||||
{
|
||||
tag: "uz-UZ-cyrillic",
|
||||
maximized: "uz-Latn-UZ-cyrillic",
|
||||
minimized: "uz-cyrillic",
|
||||
},
|
||||
{
|
||||
tag: "posix",
|
||||
},
|
||||
{
|
||||
tag: "hi-direct",
|
||||
maximized: "hi-Deva-IN-direct",
|
||||
},
|
||||
{
|
||||
tag: "zh-pinyin",
|
||||
maximized: "zh-Hans-CN-pinyin",
|
||||
},
|
||||
{
|
||||
tag: "zh-stroke",
|
||||
maximized: "zh-Hans-CN-stroke",
|
||||
},
|
||||
{
|
||||
tag: "aar-x-private",
|
||||
},
|
||||
{
|
||||
tag: "heb-x-private",
|
||||
},
|
||||
{
|
||||
tag: "und-ita",
|
||||
// canonical: "und" or "ita" ?
|
||||
maximized: "en-Latn-US",
|
||||
minimized: "und",
|
||||
},
|
||||
{
|
||||
tag: "de-u-kf",
|
||||
maximized: "de-Latn-DE-u-kf",
|
||||
},
|
||||
{
|
||||
tag: "ces",
|
||||
},
|
||||
{
|
||||
tag: "hy-arevela",
|
||||
canonical: "hy",
|
||||
maximized: "hy-Armn-AM",
|
||||
},
|
||||
{
|
||||
tag: "hy-arevmda",
|
||||
canonical: "hyw",
|
||||
},
|
||||
];
|
||||
|
||||
for (const {tag, canonical = tag, maximized = canonical, minimized = canonical} of testData) {
|
||||
assert.sameValue(Intl.getCanonicalLocales(tag)[0], canonical);
|
||||
|
||||
const loc = new Intl.Locale(tag);
|
||||
assert.sameValue(loc.toString(), canonical);
|
||||
assert.sameValue(loc.maximize().toString(), maximized);
|
||||
assert.sameValue(loc.minimize().toString(), minimized);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks error cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
22. Let kf be ? GetOption(options, "caseFirst", "string", « "upper", "lower", "false" », undefined).
|
||||
...
|
||||
|
||||
GetOption ( options, property, type, values, fallback )
|
||||
...
|
||||
2. d. If values is not undefined, then
|
||||
i. If values does not contain an element equal to value, throw a RangeError exception.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
|
||||
const invalidCaseFirstOptions = [
|
||||
"",
|
||||
"u",
|
||||
"Upper",
|
||||
"upper\0",
|
||||
"uppercase",
|
||||
"true",
|
||||
{ valueOf() { return false; } },
|
||||
];
|
||||
for (const invalidCaseFirstOption of invalidCaseFirstOptions) {
|
||||
assert.throws(RangeError, function() {
|
||||
new Intl.Locale("en", {caseFirst: invalidCaseFirstOption});
|
||||
}, `${invalidCaseFirstOption} is an invalid caseFirst option value`);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks valid cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
22. Let kf be ? GetOption(options, "caseFirst", "string", « "upper", "lower", "false" », undefined).
|
||||
23. Set opt.[[kf]] to kf.
|
||||
...
|
||||
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
||||
...
|
||||
|
||||
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
||||
|
||||
...
|
||||
8. Let locale be the String value that is tag with all Unicode locale extension sequences removed.
|
||||
9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords).
|
||||
10. If newExtension is not the empty String, then
|
||||
a. Let locale be ! InsertUnicodeExtension(locale, newExtension).
|
||||
...
|
||||
|
||||
CanonicalizeUnicodeExtension( attributes, keywords )
|
||||
...
|
||||
4. Repeat for each element entry of keywords in List order,
|
||||
a. Let keyword be entry.[[Key]].
|
||||
b. If entry.[[Value]] is not the empty String, then
|
||||
i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]].
|
||||
c. Append keyword to fullKeywords.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validCaseFirstOptions = [
|
||||
"upper",
|
||||
"lower",
|
||||
"false",
|
||||
false,
|
||||
{ toString() { return false; } },
|
||||
];
|
||||
for (const caseFirst of validCaseFirstOptions) {
|
||||
const options = { caseFirst };
|
||||
const expected = String(caseFirst);
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en', options).toString(),
|
||||
"en-u-kf-" + expected,
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-kf-lower', options).toString(),
|
||||
"en-u-kf-" + expected,
|
||||
);
|
||||
|
||||
if ("caseFirst" in Intl.Locale.prototype) {
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-kf-lower', options).caseFirst,
|
||||
expected,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks error cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
18. If collation is not undefined, then
|
||||
a. If collation does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception.
|
||||
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
|
||||
/*
|
||||
alphanum = (ALPHA / DIGIT) ; letters and numbers
|
||||
collation = [(3*8alphanum) *("-" (3*8alphanum))]
|
||||
*/
|
||||
const invalidCollationOptions = [
|
||||
"a",
|
||||
"ab",
|
||||
"abcdefghi",
|
||||
"abc-abcdefghi",
|
||||
];
|
||||
for (const invalidCollationOption of invalidCollationOptions) {
|
||||
assert.throws(RangeError, function() {
|
||||
new Intl.Locale("en", {collation: invalidCollationOption});
|
||||
}, `${invalidCollationOption} is an invalid collation option value`);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks valid cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
17. Let collation be ? GetOption(options, "collation", "string", undefined, undefined).
|
||||
...
|
||||
19. Set opt.[[co]] to collation.
|
||||
...
|
||||
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
||||
...
|
||||
|
||||
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
||||
|
||||
...
|
||||
8. Let locale be the String value that is tag with all Unicode locale extension sequences removed.
|
||||
9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords).
|
||||
10. If newExtension is not the empty String, then
|
||||
a. Let locale be ! InsertUnicodeExtension(locale, newExtension).
|
||||
...
|
||||
|
||||
CanonicalizeUnicodeExtension( attributes, keywords )
|
||||
...
|
||||
4. Repeat for each element entry of keywords in List order,
|
||||
a. Let keyword be entry.[[Key]].
|
||||
b. If entry.[[Value]] is not the empty String, then
|
||||
i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]].
|
||||
c. Append keyword to fullKeywords.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validCollationOptions = [
|
||||
["", "en-u-co"],
|
||||
["abc", "en-u-co-abc"],
|
||||
["abcd", "en-u-co-abcd"],
|
||||
["abcde", "en-u-co-abcde"],
|
||||
["abcdef", "en-u-co-abcdef"],
|
||||
["abcdefg", "en-u-co-abcdefg"],
|
||||
["abcdefgh", "en-u-co-abcdefgh"],
|
||||
["12345678", "en-u-co-12345678"],
|
||||
["1234abcd", "en-u-co-1234abcd"],
|
||||
["1234abcd-abc123", "en-u-co-1234abcd-abc123"],
|
||||
];
|
||||
for (const [collation, expected] of validCollationOptions) {
|
||||
let options = { collation };
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en', options).toString(),
|
||||
expected,
|
||||
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
||||
);
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-co-gregory', options).toString(),
|
||||
expected,
|
||||
`new Intl.Locale('en-u-co-gregory', options).toString() equals the value of ${expected}`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks error cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
20. Let hc be ? GetOption(options, "hourCycle", "string", « "h11", "h12", "h23", "h24" », undefined).
|
||||
...
|
||||
|
||||
GetOption ( options, property, type, values, fallback )
|
||||
...
|
||||
2. d. If values is not undefined, then
|
||||
i. If values does not contain an element equal to value, throw a RangeError exception.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
|
||||
const invalidHourCycleOptions = [
|
||||
"",
|
||||
"h",
|
||||
"h00",
|
||||
"h01",
|
||||
"h10",
|
||||
"h13",
|
||||
"h22",
|
||||
"h25",
|
||||
"h48",
|
||||
"h012",
|
||||
"h120",
|
||||
"h12\0",
|
||||
"H12",
|
||||
];
|
||||
for (const invalidHourCycleOption of invalidHourCycleOptions) {
|
||||
assert.throws(RangeError, function() {
|
||||
new Intl.Locale("en", {hourCycle: invalidHourCycleOption});
|
||||
}, `${invalidHourCycleOption} is an invalid hourCycle option value`);
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks valid cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
20. Let hc be ? GetOption(options, "hourCycle", "string", « "h11", "h12", "h23", "h24" », undefined).
|
||||
21. Set opt.[[hc]] to hc.
|
||||
...
|
||||
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
||||
...
|
||||
|
||||
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
||||
|
||||
...
|
||||
8. Let locale be the String value that is tag with all Unicode locale extension sequences removed.
|
||||
9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords).
|
||||
10. If newExtension is not the empty String, then
|
||||
a. Let locale be ! InsertUnicodeExtension(locale, newExtension).
|
||||
...
|
||||
|
||||
CanonicalizeUnicodeExtension( attributes, keywords )
|
||||
...
|
||||
4. Repeat for each element entry of keywords in List order,
|
||||
a. Let keyword be entry.[[Key]].
|
||||
b. If entry.[[Value]] is not the empty String, then
|
||||
i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]].
|
||||
c. Append keyword to fullKeywords.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validHourCycleOptions = [
|
||||
"h11",
|
||||
"h12",
|
||||
"h23",
|
||||
"h24",
|
||||
{ toString() { return "h24"; } },
|
||||
];
|
||||
for (const hourCycle of validHourCycleOptions) {
|
||||
const options = { hourCycle };
|
||||
const expected = String(hourCycle);
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en', options).toString(),
|
||||
"en-u-hc-" + expected,
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-hc-h00', options).toString(),
|
||||
"en-u-hc-" + expected,
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-hc-h12', options).toString(),
|
||||
"en-u-hc-" + expected,
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-hc-h00', options).hourCycle,
|
||||
expected,
|
||||
);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
// 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: >
|
||||
Checks error cases for the options argument to the Locale
|
||||
constructor.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
...
|
||||
3. Let language be ? GetOption(options, "language", "string", undefined, undefined).
|
||||
4. If language is not undefined, then
|
||||
a. If language does not match the language production, throw a RangeError exception.
|
||||
b. If language matches the grandfathered production, throw a RangeError exception.
|
||||
...
|
||||
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const testData = [
|
||||
{
|
||||
tag: "nb",
|
||||
options: {
|
||||
language: "no-bok",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
tag: "nb",
|
||||
options: {
|
||||
language: "no-bok",
|
||||
region: "NO",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const {tag, options} of testData) {
|
||||
assert.throws(RangeError, function() {
|
||||
new Intl.Locale(tag, options);
|
||||
});
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks error cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
28. If numberingSystem is not undefined, then
|
||||
a. If numberingSystem does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception.
|
||||
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
|
||||
/*
|
||||
alphanum = (ALPHA / DIGIT) ; letters and numbers
|
||||
numberingSystem = [(3*8alphanum) *("-" (3*8alphanum))]
|
||||
*/
|
||||
const invalidNumberingSystemOptions = [
|
||||
"a",
|
||||
"ab",
|
||||
"abcdefghi",
|
||||
"abc-abcdefghi",
|
||||
];
|
||||
for (const invalidNumberingSystemOption of invalidNumberingSystemOptions) {
|
||||
assert.throws(RangeError, function() {
|
||||
new Intl.Locale("en", {numberingSystem: invalidNumberingSystemOption});
|
||||
}, `${invalidNumberingSystemOption} is an invalid numberingSystem option value`);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks valid cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
27. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
|
||||
...
|
||||
29. Set opt.[[nu]] to numberingSystem.
|
||||
...
|
||||
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
||||
...
|
||||
|
||||
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
||||
|
||||
...
|
||||
8. Let locale be the String value that is tag with all Unicode locale extension sequences removed.
|
||||
9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords).
|
||||
10. If newExtension is not the empty String, then
|
||||
a. Let locale be ! InsertUnicodeExtension(locale, newExtension).
|
||||
...
|
||||
|
||||
CanonicalizeUnicodeExtension( attributes, keywords )
|
||||
...
|
||||
4. Repeat for each element entry of keywords in List order,
|
||||
a. Let keyword be entry.[[Key]].
|
||||
b. If entry.[[Value]] is not the empty String, then
|
||||
i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]].
|
||||
c. Append keyword to fullKeywords.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validNumberingSystemOptions = [
|
||||
["", "en-u-nu"],
|
||||
["abc", "en-u-nu-abc"],
|
||||
["abcd", "en-u-nu-abcd"],
|
||||
["abcde", "en-u-nu-abcde"],
|
||||
["abcdef", "en-u-nu-abcdef"],
|
||||
["abcdefg", "en-u-nu-abcdefg"],
|
||||
["abcdefgh", "en-u-nu-abcdefgh"],
|
||||
["12345678", "en-u-nu-12345678"],
|
||||
["1234abcd", "en-u-nu-1234abcd"],
|
||||
["1234abcd-abc123", "en-u-nu-1234abcd-abc123"],
|
||||
];
|
||||
for (const [numberingSystem, expected] of validNumberingSystemOptions) {
|
||||
let options = { numberingSystem };
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en', options).toString(),
|
||||
expected,
|
||||
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
|
||||
);
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-nu-latn', options).toString(),
|
||||
expected,
|
||||
`new Intl.Locale('en-u-nu-latn', options).toString() equals the value of ${expected}`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks valid cases for the options argument to the Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
24. Let kn be ? GetOption(options, "numeric", "boolean", undefined, undefined).
|
||||
25. If kn is not undefined, set kn to ! ToString(kn).
|
||||
...
|
||||
30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
||||
...
|
||||
|
||||
ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys )
|
||||
|
||||
...
|
||||
8. Let locale be the String value that is tag with all Unicode locale extension sequences removed.
|
||||
9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords).
|
||||
10. If newExtension is not the empty String, then
|
||||
a. Let locale be ! InsertUnicodeExtension(locale, newExtension).
|
||||
...
|
||||
|
||||
CanonicalizeUnicodeExtension( attributes, keywords )
|
||||
...
|
||||
4. Repeat for each element entry of keywords in List order,
|
||||
a. Let keyword be entry.[[Key]].
|
||||
b. If entry.[[Value]] is not the empty String, then
|
||||
i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]].
|
||||
c. Append keyword to fullKeywords.
|
||||
...
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validNumericOptions = [
|
||||
[undefined, undefined],
|
||||
[false, "false"],
|
||||
[true, "true"],
|
||||
[null, "false"],
|
||||
[0, "false"],
|
||||
[0.5, "true"],
|
||||
[{ valueOf() { return false; } }, "true"],
|
||||
];
|
||||
for (const [numeric, expected] of validNumericOptions) {
|
||||
const options = { numeric };
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en', options).toString(),
|
||||
expected ? ("en-u-kn-" + expected) : "en",
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-kn-true', options).toString(),
|
||||
"en-u-kn-" + (expected || "true"),
|
||||
);
|
||||
|
||||
if ("numeric" in Intl.Locale.prototype) {
|
||||
assert.sameValue(
|
||||
new Intl.Locale('en-u-kf-lower', options).numeric,
|
||||
expected,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
// 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 the handling of options with grandfathered tags.
|
||||
info: |
|
||||
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).
|
||||
|
||||
ApplyOptionsToTag( tag, options )
|
||||
9. If tag matches neither the privateuse nor the grandfathered production, then
|
||||
10. Return CanonicalizeLanguageTag(tag).
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const testData = [
|
||||
// Irregular grandfathered tags.
|
||||
|
||||
// "en-GB-oed" is a grandfathered tag, so we can't add "US". After it is
|
||||
// canonicalized to "en-GB-oxendict" we can append "u-ca-gregory".
|
||||
{
|
||||
tag: "en-GB-oed",
|
||||
options: {
|
||||
region: "US",
|
||||
calendar: "gregory",
|
||||
},
|
||||
canonical: "en-GB-oxendict-u-ca-gregory",
|
||||
},
|
||||
|
||||
// Canonicalized version of the above, which we can add "US" to.
|
||||
{
|
||||
tag: "en-GB-oxendict",
|
||||
options: {
|
||||
region: "US",
|
||||
calendar: "gregory",
|
||||
},
|
||||
canonical: "en-US-oxendict-u-ca-gregory",
|
||||
},
|
||||
|
||||
// Regular grandfathered tags.
|
||||
|
||||
// "no-bok" is a grandfathered, so "NO"/"SE" isn't added. After
|
||||
// canonicalization we can append "u-ca-gregory".
|
||||
{
|
||||
tag: "no-bok",
|
||||
options: {
|
||||
region: "NO",
|
||||
calendar: "gregory",
|
||||
},
|
||||
canonical: "nb-u-ca-gregory",
|
||||
},
|
||||
|
||||
{
|
||||
tag: "no-bok",
|
||||
options: {
|
||||
region: "SE",
|
||||
calendar: "gregory",
|
||||
},
|
||||
canonical: "nb-u-ca-gregory",
|
||||
},
|
||||
|
||||
// "no-bok-NO" isn't a grandfathered tag, so we can replace "NO" with "SE"
|
||||
// and can also append "u-ca-gregory".
|
||||
{
|
||||
tag: "no-bok-NO",
|
||||
options: {
|
||||
region: "SE",
|
||||
calendar: "gregory",
|
||||
},
|
||||
canonical: "no-bok-SE-u-ca-gregory",
|
||||
},
|
||||
|
||||
// "no-bok-SE" isn't a grandfathered tag, so we can replace "SE" with "NO"
|
||||
// and can also append "u-ca-gregory".
|
||||
{
|
||||
tag: "no-bok-SE",
|
||||
options: {
|
||||
region: "NO",
|
||||
calendar: "gregory",
|
||||
},
|
||||
canonical: "no-bok-NO-u-ca-gregory",
|
||||
},
|
||||
];
|
||||
|
||||
for (const {tag, options, canonical} of testData) {
|
||||
const loc = new Intl.Locale(tag, options);
|
||||
assert.sameValue(loc.toString(), canonical);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks error cases for the string conversion of the locale argument to the
|
||||
Locale constructor.
|
||||
info: |
|
||||
Intl.Locale( tag [, options] )
|
||||
|
||||
...
|
||||
8. If Type(tag) is Object and tag has an [[InitializedLocale]] internal slot, then
|
||||
9. Else,
|
||||
a. Let tag be ? ToString(tag).
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
function CustomError() {}
|
||||
function WrongCustomError() {}
|
||||
|
||||
const errors = [
|
||||
{ get [Symbol.toPrimitive]() { throw new CustomError(); } },
|
||||
{ [Symbol.toPrimitive](hint) { assert.sameValue(hint, "string"); throw new CustomError(); } },
|
||||
{ get toString() { throw new CustomError(); }, get valueOf() { throw new WrongCustomError(); } },
|
||||
{ toString() { throw new CustomError(); }, get valueOf() { throw new WrongCustomError(); } },
|
||||
{ toString: undefined, get valueOf() { throw new CustomError(); } },
|
||||
{ toString: undefined, valueOf() { throw new CustomError(); } },
|
||||
{ toString() { return {} }, get valueOf() { throw new CustomError(); } },
|
||||
{ toString() { return {} }, valueOf() { throw new CustomError(); } },
|
||||
];
|
||||
|
||||
for (const input of errors) {
|
||||
assert.throws(CustomError, function() { new Intl.Locale(input) });
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// 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 treatment of specific structurally invalid tags.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const invalidLanguageTags = [
|
||||
// Unicode extension sequence is incomplete.
|
||||
"da-u",
|
||||
"da-u-",
|
||||
"da-u--",
|
||||
"da-u-t-latn",
|
||||
"da-u-x-priv",
|
||||
|
||||
// Duplicate 'u' singleton.
|
||||
"da-u-ca-gregory-u-ca-buddhist"
|
||||
];
|
||||
|
||||
for (const langtag of invalidLanguageTags) {
|
||||
assert.throws(RangeError, function() {
|
||||
new Intl.Locale(langtag)
|
||||
});
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// 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 canonicalization of specific tags.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
10. Return CanonicalizeLanguageTag(tag).
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const validLanguageTags = {
|
||||
// Duplicate keywords are removed.
|
||||
"da-u-ca-gregory-ca-buddhist": "da-u-ca-gregory",
|
||||
|
||||
// Keywords currently used in Intl specs are reordered in US-ASCII order.
|
||||
"zh-u-nu-hans-ca-chinese": "zh-u-ca-chinese-nu-hans",
|
||||
"zh-u-ca-chinese-nu-hans": "zh-u-ca-chinese-nu-hans",
|
||||
|
||||
// Even keywords currently not used in Intl specs are reordered in US-ASCII order.
|
||||
"de-u-cu-eur-nu-latn": "de-u-cu-eur-nu-latn",
|
||||
"de-u-nu-latn-cu-eur": "de-u-cu-eur-nu-latn",
|
||||
|
||||
// Attributes in Unicode extensions are reordered in US-ASCII order.
|
||||
"pt-u-attr-ca-gregory": "pt-u-attr-ca-gregory",
|
||||
"pt-u-attr1-attr2-ca-gregory": "pt-u-attr1-attr2-ca-gregory",
|
||||
"pt-u-attr2-attr1-ca-gregory": "pt-u-attr1-attr2-ca-gregory",
|
||||
};
|
||||
|
||||
for (const [langtag, canonical] of Object.entries(validLanguageTags)) {
|
||||
assert.sameValue(new Intl.Locale(langtag).toString(), canonical);
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
// 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",
|
||||
},
|
||||
canonical: "i-default",
|
||||
extensions: {
|
||||
language: undefined,
|
||||
script: undefined,
|
||||
region: undefined,
|
||||
numberingSystem: undefined,
|
||||
},
|
||||
},
|
||||
|
||||
// Irregular grandfathered with modern replacement.
|
||||
{
|
||||
tag: "en-gb-oed",
|
||||
options: {
|
||||
language: "fr",
|
||||
script: "Cyrl",
|
||||
region: "US",
|
||||
numberingSystem: "latn",
|
||||
},
|
||||
canonical: "en-GB-oxendict-u-nu-latn",
|
||||
extensions: {
|
||||
language: "en",
|
||||
script: undefined,
|
||||
region: "GB",
|
||||
numberingSystem: "latn",
|
||||
},
|
||||
},
|
||||
|
||||
// Regular grandfathered without modern replacement.
|
||||
{
|
||||
tag: "cel-gaulish",
|
||||
options: {
|
||||
language: "fr",
|
||||
script: "Cyrl",
|
||||
region: "FR",
|
||||
numberingSystem: "latn",
|
||||
},
|
||||
canonical: "cel-gaulish",
|
||||
extensions: {
|
||||
language: undefined,
|
||||
script: undefined,
|
||||
region: undefined,
|
||||
numberingSystem: undefined,
|
||||
},
|
||||
},
|
||||
|
||||
// Regular grandfathered with modern replacement.
|
||||
{
|
||||
tag: "art-lojban",
|
||||
options: {
|
||||
language: "fr",
|
||||
script: "Cyrl",
|
||||
region: "ZZ",
|
||||
numberingSystem: "latn",
|
||||
},
|
||||
canonical: "jbo-u-nu-latn",
|
||||
extensions: {
|
||||
language: "jbo",
|
||||
script: undefined,
|
||||
region: undefined,
|
||||
numberingSystem: "latn",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const {tag, options, canonical, extensions} of testData) {
|
||||
const loc = new Intl.Locale(tag, options);
|
||||
assert.sameValue(loc.toString(), canonical);
|
||||
|
||||
for (const [name, value] of Object.entries(extensions)) {
|
||||
assert.sameValue(loc[name], value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2018 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 privateuse 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 loc = new Intl.Locale("x-default", {
|
||||
language: "fr",
|
||||
script: "Cyrl",
|
||||
region: "DE",
|
||||
numberingSystem: "latn",
|
||||
});
|
||||
assert.sameValue(loc.toString(), "x-default");
|
||||
assert.sameValue(loc.language, undefined);
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
||||
assert.sameValue(loc.numberingSystem, undefined);
|
|
@ -0,0 +1,45 @@
|
|||
// 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 getters with grandfathered tags.
|
||||
info: |
|
||||
get Intl.Locale.prototype.baseName
|
||||
4. If locale does not match the langtag production, return locale.
|
||||
5. Return the substring of locale corresponding to the
|
||||
language ["-" script] ["-" region] *("-" variant)
|
||||
subsequence of the langtag grammar.
|
||||
|
||||
get Intl.Locale.prototype.language
|
||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
||||
|
||||
get Intl.Locale.prototype.script
|
||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
||||
|
||||
get Intl.Locale.prototype.region
|
||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
// Irregular grandfathered language tag.
|
||||
var loc = new Intl.Locale("i-default");
|
||||
assert.sameValue(loc.baseName, "i-default"); // Step 4.
|
||||
assert.sameValue(loc.language, undefined);
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
||||
|
||||
// Regular grandfathered language tag.
|
||||
var loc = new Intl.Locale("cel-gaulish");
|
||||
assert.sameValue(loc.baseName, "cel-gaulish"); // Step 5.
|
||||
assert.sameValue(loc.language, undefined);
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
||||
|
||||
// Regular grandfathered language tag.
|
||||
var loc = new Intl.Locale("zh-min");
|
||||
assert.sameValue(loc.baseName, "zh-min"); // Step 5.
|
||||
assert.sameValue(loc.language, undefined);
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
|
@ -0,0 +1,53 @@
|
|||
// 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 getters with missing tags.
|
||||
info: |
|
||||
get Intl.Locale.prototype.baseName
|
||||
5. Return the substring of locale corresponding to the
|
||||
language ["-" script] ["-" region] *("-" variant)
|
||||
subsequence of the langtag grammar.
|
||||
|
||||
get Intl.Locale.prototype.language
|
||||
4. Return the substring of locale corresponding to the language production.
|
||||
|
||||
get Intl.Locale.prototype.script
|
||||
6. If locale does not contain the ["-" script] sequence, return undefined.
|
||||
7. Return the substring of locale corresponding to the script production.
|
||||
|
||||
get Intl.Locale.prototype.region
|
||||
6. If locale does not contain the ["-" region] sequence, return undefined.
|
||||
7. Return the substring of locale corresponding to the region production.
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
// 'script' and 'region' subtags not present.
|
||||
var loc = new Intl.Locale("sv");
|
||||
assert.sameValue(loc.baseName, "sv");
|
||||
assert.sameValue(loc.language, "sv");
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
||||
|
||||
// 'region' subtag not present.
|
||||
var loc = new Intl.Locale("sv-Latn");
|
||||
assert.sameValue(loc.baseName, "sv-Latn");
|
||||
assert.sameValue(loc.language, "sv");
|
||||
assert.sameValue(loc.script, "Latn");
|
||||
assert.sameValue(loc.region, undefined);
|
||||
|
||||
// 'script' subtag not present.
|
||||
var loc = new Intl.Locale("sv-SE");
|
||||
assert.sameValue(loc.baseName, "sv-SE");
|
||||
assert.sameValue(loc.language, "sv");
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, "SE");
|
||||
|
||||
// 'variant' subtag present.
|
||||
var loc = new Intl.Locale("de-1901");
|
||||
assert.sameValue(loc.baseName, "de-1901");
|
||||
assert.sameValue(loc.language, "de");
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
|
@ -0,0 +1,28 @@
|
|||
// 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 getters with privateuse tags.
|
||||
info: |
|
||||
get Intl.Locale.prototype.baseName
|
||||
4. If locale does not match the langtag production, return locale.
|
||||
|
||||
get Intl.Locale.prototype.language
|
||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
||||
|
||||
get Intl.Locale.prototype.script
|
||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
||||
|
||||
get Intl.Locale.prototype.region
|
||||
4. If locale matches the privateuse or the grandfathered production, return undefined.
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
// Privateuse only language tag.
|
||||
var loc = new Intl.Locale("x-private");
|
||||
assert.sameValue(loc.baseName, "x-private");
|
||||
assert.sameValue(loc.language, undefined);
|
||||
assert.sameValue(loc.script, undefined);
|
||||
assert.sameValue(loc.region, undefined);
|
|
@ -0,0 +1,122 @@
|
|||
// 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 getters with normal tags.
|
||||
info: |
|
||||
Intl.Locale.prototype.toString ()
|
||||
3. Return loc.[[Locale]].
|
||||
|
||||
get Intl.Locale.prototype.baseName
|
||||
5. Return the substring of locale corresponding to the
|
||||
language ["-" script] ["-" region] *("-" variant)
|
||||
subsequence of the langtag grammar.
|
||||
|
||||
get Intl.Locale.prototype.language
|
||||
4. Return the substring of locale corresponding to the language production.
|
||||
|
||||
get Intl.Locale.prototype.script
|
||||
7. Return the substring of locale corresponding to the script production.
|
||||
|
||||
get Intl.Locale.prototype.region
|
||||
7. Return the substring of locale corresponding to the region production.
|
||||
|
||||
get Intl.Locale.prototype.calendar
|
||||
3. Return loc.[[Calendar]].
|
||||
|
||||
get Intl.Locale.prototype.collation
|
||||
3. Return loc.[[Collation]].
|
||||
|
||||
get Intl.Locale.prototype.hourCycle
|
||||
3. Return loc.[[HourCycle]].
|
||||
|
||||
get Intl.Locale.prototype.caseFirst
|
||||
This property only exists if %Locale%.[[RelevantExtensionKeys]] contains "kf".
|
||||
3. Return loc.[[CaseFirst]].
|
||||
|
||||
get Intl.Locale.prototype.numeric
|
||||
This property only exists if %Locale%.[[RelevantExtensionKeys]] contains "kn".
|
||||
3. Return loc.[[Numeric]].
|
||||
|
||||
get Intl.Locale.prototype.numberingSystem
|
||||
3. Return loc.[[NumberingSystem]].
|
||||
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
// Test all getters return the expected results.
|
||||
var langtag = "de-latn-de-u-ca-gregory-co-phonebk-hc-h23-kf-true-kn-false-nu-latn";
|
||||
var loc = new Intl.Locale(langtag);
|
||||
|
||||
assert.sameValue(loc.toString(), "de-Latn-DE-u-ca-gregory-co-phonebk-hc-h23-kf-true-kn-false-nu-latn");
|
||||
assert.sameValue(loc.baseName, "de-Latn-DE");
|
||||
assert.sameValue(loc.language, "de");
|
||||
assert.sameValue(loc.script, "Latn");
|
||||
assert.sameValue(loc.region, "DE");
|
||||
assert.sameValue(loc.calendar, "gregory");
|
||||
assert.sameValue(loc.collation, "phonebk");
|
||||
assert.sameValue(loc.hourCycle, "h23");
|
||||
if ("caseFirst" in loc) {
|
||||
assert.sameValue(loc.caseFirst, "true");
|
||||
}
|
||||
if ("numeric" in loc) {
|
||||
assert.sameValue(loc.numeric, "false");
|
||||
}
|
||||
assert.sameValue(loc.numberingSystem, "latn");
|
||||
|
||||
// Replace all components through option values and validate the getters still
|
||||
// return the expected results.
|
||||
var loc = new Intl.Locale(langtag, {
|
||||
language: "ja",
|
||||
script: "jpan",
|
||||
region: "jp",
|
||||
calendar: "japanese",
|
||||
collation: "search",
|
||||
hourCycle: "h24",
|
||||
caseFirst: "false",
|
||||
numeric: "true",
|
||||
numberingSystem: "jpanfin",
|
||||
});
|
||||
|
||||
assert.sameValue(loc.toString(), "ja-Jpan-JP-u-ca-japanese-co-search-hc-h24-kf-false-kn-true-nu-jpanfin");
|
||||
assert.sameValue(loc.baseName, "ja-Jpan-JP");
|
||||
assert.sameValue(loc.language, "ja");
|
||||
assert.sameValue(loc.script, "Jpan");
|
||||
assert.sameValue(loc.region, "JP");
|
||||
assert.sameValue(loc.calendar, "japanese");
|
||||
assert.sameValue(loc.collation, "search");
|
||||
assert.sameValue(loc.hourCycle, "h24");
|
||||
if ("caseFirst" in loc) {
|
||||
assert.sameValue(loc.caseFirst, "false");
|
||||
}
|
||||
if ("numeric" in loc) {
|
||||
assert.sameValue(loc.numeric, "true");
|
||||
}
|
||||
assert.sameValue(loc.numberingSystem, "jpanfin");
|
||||
|
||||
// Replace only some components through option values and validate the getters
|
||||
// return the expected results.
|
||||
var loc = new Intl.Locale(langtag, {
|
||||
language: "fr",
|
||||
region: "ca",
|
||||
collation: "standard",
|
||||
hourCycle: "h11",
|
||||
});
|
||||
|
||||
assert.sameValue(loc.toString(), "fr-Latn-CA-u-ca-gregory-co-standard-hc-h11-kf-true-kn-false-nu-latn");
|
||||
assert.sameValue(loc.baseName, "fr-Latn-CA");
|
||||
assert.sameValue(loc.language, "fr");
|
||||
assert.sameValue(loc.script, "Latn");
|
||||
assert.sameValue(loc.region, "CA");
|
||||
assert.sameValue(loc.calendar, "gregory");
|
||||
assert.sameValue(loc.collation, "standard");
|
||||
assert.sameValue(loc.hourCycle, "h11");
|
||||
if ("caseFirst" in loc) {
|
||||
assert.sameValue(loc.caseFirst, "true");
|
||||
}
|
||||
if ("numeric" in loc) {
|
||||
assert.sameValue(loc.numeric, "false");
|
||||
}
|
||||
assert.sameValue(loc.numberingSystem, "latn");
|
|
@ -0,0 +1,202 @@
|
|||
// 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 canonicalization, minimization and maximization of specific tags.
|
||||
info: |
|
||||
ApplyOptionsToTag( tag, options )
|
||||
10. Return CanonicalizeLanguageTag(tag).
|
||||
|
||||
Intl.Locale.prototype.maximize ()
|
||||
3. Let maximal be the result of the Add Likely Subtags algorithm applied to loc.[[Locale]].
|
||||
|
||||
Intl.Locale.prototype.minimize ()
|
||||
3. Let minimal be the result of the Remove Likely Subtags algorithm applied to loc.[[Locale]].
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const irregularGrandfathered = [
|
||||
{
|
||||
tag: "en-GB-oed",
|
||||
canonical: "en-GB-oxendict",
|
||||
maximized: "en-Latn-GB-oxendict",
|
||||
},
|
||||
{
|
||||
tag: "i-ami",
|
||||
canonical: "ami",
|
||||
},
|
||||
{
|
||||
tag: "i-bnn",
|
||||
canonical: "bnn",
|
||||
},
|
||||
{
|
||||
tag: "i-default",
|
||||
canonical: "i-default",
|
||||
},
|
||||
{
|
||||
tag: "i-enochian",
|
||||
canonical: "i-enochian",
|
||||
},
|
||||
{
|
||||
tag: "i-hak",
|
||||
canonical: "hak",
|
||||
maximized: "hak-Hans-CN",
|
||||
},
|
||||
{
|
||||
tag: "i-klingon",
|
||||
canonical: "tlh",
|
||||
},
|
||||
{
|
||||
tag: "i-lux",
|
||||
canonical: "lb",
|
||||
maximized: "lb-Latn-LU",
|
||||
},
|
||||
{
|
||||
tag: "i-mingo",
|
||||
canonical: "i-mingo",
|
||||
},
|
||||
{
|
||||
tag: "i-navajo",
|
||||
canonical: "nv",
|
||||
maximized: "nv-Latn-US",
|
||||
},
|
||||
{
|
||||
tag: "i-pwn",
|
||||
canonical: "pwn",
|
||||
},
|
||||
{
|
||||
tag: "i-tao",
|
||||
canonical: "tao",
|
||||
},
|
||||
{
|
||||
tag: "i-tay",
|
||||
canonical: "tay",
|
||||
},
|
||||
{
|
||||
tag: "i-tsu",
|
||||
canonical: "tsu",
|
||||
},
|
||||
{
|
||||
tag: "sgn-BE-FR",
|
||||
canonical: "sfb",
|
||||
},
|
||||
{
|
||||
tag: "sgn-BE-NL",
|
||||
canonical: "vgt",
|
||||
},
|
||||
{
|
||||
tag: "sgn-CH-DE",
|
||||
canonical: "sgg",
|
||||
},
|
||||
];
|
||||
|
||||
for (const {tag, canonical, maximized = canonical, minimized = canonical} of irregularGrandfathered) {
|
||||
assert.sameValue(Intl.getCanonicalLocales(tag)[0], canonical);
|
||||
|
||||
const loc = new Intl.Locale(tag);
|
||||
assert.sameValue(loc.toString(), canonical);
|
||||
|
||||
assert.sameValue(loc.maximize().toString(), maximized);
|
||||
assert.sameValue(loc.maximize().maximize().toString(), maximized);
|
||||
|
||||
assert.sameValue(loc.minimize().toString(), minimized);
|
||||
assert.sameValue(loc.minimize().minimize().toString(), minimized);
|
||||
|
||||
assert.sameValue(loc.maximize().minimize().toString(), minimized);
|
||||
assert.sameValue(loc.minimize().maximize().toString(), maximized);
|
||||
}
|
||||
|
||||
const regularGrandfathered = [
|
||||
{
|
||||
tag: "art-lojban",
|
||||
canonical: "jbo",
|
||||
maximized: "jbo-Latn-001",
|
||||
},
|
||||
{
|
||||
tag: "cel-gaulish",
|
||||
canonical: "cel-gaulish",
|
||||
},
|
||||
{
|
||||
tag: "no-bok",
|
||||
canonical: "nb",
|
||||
maximized: "nb-Latn-NO",
|
||||
},
|
||||
{
|
||||
tag: "no-nyn",
|
||||
canonical: "nn",
|
||||
maximized: "nn-Latn-NO",
|
||||
},
|
||||
{
|
||||
tag: "zh-guoyu",
|
||||
canonical: "cmn",
|
||||
},
|
||||
{
|
||||
tag: "zh-hakka",
|
||||
canonical: "hak",
|
||||
maximized: "hak-Hans-CN",
|
||||
},
|
||||
{
|
||||
tag: "zh-min",
|
||||
canonical: "zh-min",
|
||||
},
|
||||
{
|
||||
tag: "zh-min-nan",
|
||||
canonical: "nan",
|
||||
maximized: "nan-Hans-CN",
|
||||
},
|
||||
{
|
||||
tag: "zh-xiang",
|
||||
canonical: "hsn",
|
||||
maximized: "hsn-Hans-CN",
|
||||
},
|
||||
];
|
||||
|
||||
for (const {tag, canonical, maximized = canonical, minimized = canonical} of regularGrandfathered) {
|
||||
assert.sameValue(Intl.getCanonicalLocales(tag)[0], canonical);
|
||||
|
||||
const loc = new Intl.Locale(tag);
|
||||
assert.sameValue(loc.toString(), canonical);
|
||||
|
||||
assert.sameValue(loc.maximize().toString(), maximized);
|
||||
assert.sameValue(loc.maximize().maximize().toString(), maximized);
|
||||
|
||||
assert.sameValue(loc.minimize().toString(), minimized);
|
||||
assert.sameValue(loc.minimize().minimize().toString(), minimized);
|
||||
|
||||
assert.sameValue(loc.maximize().minimize().toString(), minimized);
|
||||
assert.sameValue(loc.minimize().maximize().toString(), maximized);
|
||||
}
|
||||
|
||||
// Add constiants, extensions, and privateuse subtags to regular grandfathered
|
||||
// language tags and ensure it produces the "expected" result.
|
||||
const extras = [
|
||||
"fonipa",
|
||||
"a-not-assigned",
|
||||
"u-attr",
|
||||
"u-co",
|
||||
"u-co-phonebk",
|
||||
"x-private",
|
||||
];
|
||||
|
||||
for (const {tag} of regularGrandfathered) {
|
||||
const priv = "-x-0";
|
||||
const tagMax = new Intl.Locale(tag + priv).maximize().toString().slice(0, -priv.length);
|
||||
const tagMin = new Intl.Locale(tag + priv).minimize().toString().slice(0, -priv.length);
|
||||
|
||||
for (const extra of extras) {
|
||||
const loc = new Intl.Locale(tag + "-" + extra);
|
||||
assert.sameValue(loc.toString(), tag + "-" + extra);
|
||||
|
||||
assert.sameValue(loc.maximize().toString(), tagMax + "-" + extra);
|
||||
assert.sameValue(loc.maximize().maximize().toString(), tagMax + "-" + extra);
|
||||
|
||||
assert.sameValue(loc.minimize().toString(), tagMin + "-" + extra);
|
||||
assert.sameValue(loc.minimize().minimize().toString(), tagMin + "-" + extra);
|
||||
|
||||
assert.sameValue(loc.maximize().minimize().toString(), tagMin + "-" + extra);
|
||||
assert.sameValue(loc.minimize().maximize().toString(), tagMax + "-" + extra);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "baseName" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.baseName
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "baseName");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get baseName");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "baseName", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "calendar" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.calendar
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "calendar");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get calendar");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "calendar", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "caseFirst" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.caseFirst
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "caseFirst");
|
||||
if (propdesc) {
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get caseFirst");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "caseFirst", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "collation" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.collation
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "collation");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get collation");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "collation", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "hourCycle" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.hourCycle
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "hourCycle");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get hourCycle");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "hourCycle", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "language" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.language
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "language");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get language");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "language", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale.prototype.minimize
|
||||
description: >
|
||||
Checks the "length" property of Intl.Locale.prototype.minimize().
|
||||
info: |
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
The Locale constructor is a standard built-in property of the Intl object.
|
||||
Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count.
|
||||
Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.Locale.prototype.minimize, 'length', {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale.prototype.minimize
|
||||
description: >
|
||||
Checks the "name" property of Intl.Locale.prototype.minimize().
|
||||
info: |
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
|
||||
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.Locale.prototype.minimize, 'name', {
|
||||
value: 'minimize',
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "minimize" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.minimize ()
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Intl.Locale.prototype.minimize,
|
||||
"function",
|
||||
"typeof Intl.Locale.prototype.minimize is function"
|
||||
);
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "minimize", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "numberingSystem" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.numberingSystem
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "numberingSystem");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get numberingSystem");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "numberingSystem", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "numeric" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.numeric
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "numeric");
|
||||
if (propdesc) {
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get numeric");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "numeric", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "region" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.region
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAregion objects in the ECMAregion 2019 region Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "region");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get region");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "region", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "script" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.script
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 script Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Functions that are specified as get or set accessor functions of built-in properties have "get " or "set " prepended to the property name string.
|
||||
|
||||
Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, undefined.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale.prototype, "script");
|
||||
assert.sameValue(propdesc.set, undefined);
|
||||
assert.sameValue(typeof propdesc.get, "function");
|
||||
assert.sameValue(propdesc.get.name, "get script");
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "script", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-intl.locale
|
||||
description: >
|
||||
Checks the "toString" property of the Locale prototype object.
|
||||
info: |
|
||||
Intl.Locale.prototype.toString ()
|
||||
|
||||
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
|
||||
|
||||
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.Locale]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Intl.Locale.prototype.toString,
|
||||
"function",
|
||||
"typeof Intl.Locale.prototype.toString is function"
|
||||
);
|
||||
|
||||
verifyProperty(Intl.Locale.prototype, "toString", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
Loading…
Reference in New Issue