Skip to content
Snippets Groups Projects
Commit 83d81532 authored by Rick Waldron's avatar Rick Waldron Committed by Leo Balter
Browse files

Intl.Locale: follow up tasks, set 1. Ref gh-1538 (#1540)

parent eecf4d46
No related branches found
No related tags found
No related merge requests found
Showing
with 558 additions and 297 deletions
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the NewTarget check for Intl.Locale. Verifies the NewTarget check for Intl.Locale.
info: | info: |
Intl.Locale( tag [, options] ) Intl.Locale( tag [, options] )
1. If NewTarget is undefined, throw a TypeError exception. 1. If NewTarget is undefined, throw a TypeError exception.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
assert.throws(TypeError, () => Intl.Locale()); assert.throws(TypeError, function() {
assert.throws(TypeError, () => Intl.Locale("en")); Intl.Locale();
});
assert.throws(TypeError, function() {
Intl.Locale("en");
});
// 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: |
Intl.Locale( tag [, options] )
...
15. If calendar is not undefined, then
a. If calendar does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception.
16. Set opt.[[ca]] to calendar.
features: [Intl.Locale]
---*/
/*
alphanum = (ALPHA / DIGIT) ; letters and numbers
calendar = (3*8alphanum) *("-" (3*8alphanum))
*/
const invalidCalendarOptions = [
"",
"a",
"ab",
"abcdefghi",
"abc-abcdefghi",
];
for (const invalidCalendarOption of invalidCalendarOptions) {
assert.throws(RangeError, function() {
new Intl.Locale("en", {calendar: invalidCalendarOption});
}, `${invalidCalendarOption} is an invalid calendar option value`);
}
// 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: |
Intl.Locale( tag [, options] )
...
14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
...
features: [Intl.Locale]
---*/
const validCalendarOptions = [
["abc", "en-u-ca-abc"],
["abcd", "en-u-ca-abcd"],
["abcde", "en-u-ca-abcde"],
["abcdef", "en-u-ca-abcdef"],
["abcdefg", "en-u-ca-abcdefg"],
["abcdefgh", "en-u-ca-abcdefgh"],
["12345678", "en-u-ca-12345678"],
["1234abcd", "en-u-ca-1234abcd"],
["1234abcd-abc123", "en-u-ca-1234abcd-abc123"],
];
for (const [calendar, expected] of validCalendarOptions) {
let options = { calendar };
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-ca-gregory', options).toString(),
expected,
`new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expected}`
);
}
// 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: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options )
...
4. If language is not undefined, then
a. If language does not match the language production, throw a RangeError exception.
...
features: [Intl.Locale]
---*/
/*
language = 2*3ALPHA ; shortest ISO 639 code
["-" extlang] ; sometimes followed by
; extended language subtags
/ 4ALPHA ; or reserved for future use
/ 5*8ALPHA ; or registered language subtag
extlang = 3ALPHA ; selected ISO 639 codes
*2("-" 3ALPHA) ; permanently reserved
*/
const invalidLanguageOptions = [
"",
"a",
"ab7",
"notalanguage",
"undefined",
// Value contains more than just the 'language' production.
"fr-Latn",
"fr-FR",
"sa-vaidika",
"fr-a-asdf",
"fr-x-private",
// Irregular grandfathered language tag.
"i-klingon",
// Regular grandfathered language tag.
"zh-Hant",
// Reserved with extended language subtag
"abcd-US",
"abcde-US",
"abcdef-US",
"abcdefg-US",
"abcdefgh-US",
7,
];
for (const invalidLanguageOption of invalidLanguageOptions) {
assert.throws(RangeError, function() {
new Intl.Locale("en", {language: invalidLanguageOption});
}, `${invalidLanguageOption} is an invalid language option value`);
}
// 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: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options )
...
9. If tag matches the langtag production, then
a. If language is not undefined, then
i. Set tag to tag with the substring corresponding to the language production replaced by the string language.
features: [Intl.Locale]
---*/
const validLanguageOptions = [
[undefined, "en"],
[null, "null"],
["zh-cmn", "cmn"],
["ZH-CMN", "cmn"],
["abcd", "abcd"],
["abcde", "abcde"],
["abcdef", "abcdef"],
["abcdefg", "abcdefg"],
["abcdefgh", "abcdefgh"],
[{ toString() { return "de" } }, "de"],
];
for (const [language, expected] of validLanguageOptions) {
let options = { language };
assert.sameValue(
new Intl.Locale('en', options).toString(),
expected,
`new Intl.Locale('en', options).toString() equals the value of ${expected}`
);
}
// 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: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options )
...
8. If region is not undefined, then
a. If region does not match the region production, throw a RangeError exception.
...
features: [Intl.Locale]
---*/
/*
region = 2ALPHA ; ISO 3166-1 code
/ 3DIGIT ; UN M.49 code
*/
const invalidRegionOptions = [
"",
"a",
"abc",
"a7",
// Value cannot be parsed as a 'region' production.
"notaregion",
// Value contains more than just the 'region' production.
"SA-vaidika",
"SA-a-asdf",
"SA-x-private",
// Value contains more than just the 'script' production.
"ary-Arab",
"Latn-SA",
"Latn-vaidika",
"Latn-a-asdf",
"Latn-x-private",
7,
];
for (const invalidRegionOption of invalidRegionOptions) {
assert.throws(RangeError, function() {
new Intl.Locale("en", {region: invalidRegionOption});
}, `${invalidRegionOption} is an invalid region option value`);
}
// 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: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options )
...
7. Let region be ? GetOption(options, "region", "string", undefined, undefined).
...
9. If tag matches the langtag production, then
...
c. If region is not undefined, then
i. If tag does not contain a region production, then
1. Set tag to the concatenation of the language production of tag, the substring corresponding to the "-" script production if present, "-", region, and the rest of tag.
features: [Intl.Locale]
---*/
const validRegionOptions = [
["FR", "en-FR"],
["554", "en-554"],
[554, "en-554"],
];
for (const [region, expected] of validRegionOptions) {
let options = { region };
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-US', options).toString(),
expected,
`new Intl.Locale('en-US', options).toString() equals the value of ${expected}`
);
}
// 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: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options )
...
6. If script is not undefined, then
a. If script does not match the script production, throw a RangeError exception.
...
features: [Intl.Locale]
---*/
/*
script = 4ALPHA ; ISO 15924 code
*/
const invalidScriptOptions = [
"",
"a",
"ab",
"abc",
"abc7",
"notascript",
"undefined",
"Bal\u0130",
"Bal\u0131",
// Value contains more than just the 'script' production.
"ary-Arab",
"Latn-SA",
"Latn-vaidika",
"Latn-a-asdf",
"Latn-x-private",
7,
];
for (const invalidScriptOption of invalidScriptOptions) {
assert.throws(RangeError, function() {
new Intl.Locale("en", {script: invalidScriptOption});
}, `${invalidScriptOption} is an invalid script option value`);
}
// 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: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
ApplyOptionsToTag( tag, options )
...
5. Let script be ? GetOption(options, "script", "string", undefined, undefined).
...
9. If tag matches the langtag production, then
...
b. If script is not undefined, then
i. If tag does not contain a script production, then
1. Set tag to the concatenation of the language production of tag, "-", script, and the rest of tag.
ii. Else,
1. Set tag to tag with the substring corresponding to the script production replaced by the string script.
features: [Intl.Locale]
---*/
const validScriptOptions = [
[null, "en-Null"],
["bali", "en-Bali"],
["Bali", "en-Bali"],
["bALI", "en-BALI"], // TODO REVIEW: is this the correct case regularization?
[{ toString() { return "Brai" } }, "en-Brai"],
];
for (const [script, expected] of validScriptOptions) {
let options = { script };
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-Cyrl", options).toString(),
expected,
`new Intl.Locale("en-Cyrl", options).toString() equals the value of ${expected}`
);
}
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: >
Checks error cases for the options argument to the Locale
constructor.
info: |
Intl.Locale( tag [, options] )
10. If options is undefined, then
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
15. If calendar is not undefined, then
a. If calendar does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception.
16. Set opt.[[ca]] to calendar.
ApplyOptionsToTag( tag, options )
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
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.
5. Let script be ? GetOption(options, "script", "string", undefined, undefined).
6. If script is not undefined, then
a. If script does not match the script production, throw a RangeError exception.
7. Let region be ? GetOption(options, "region", "string", undefined, undefined).
8. If region is not undefined, then
a. If region does not match the region production, throw a RangeError exception.
9. If tag matches the langtag production, then
a. If language is not undefined, then
i. Set tag to tag with the substring corresponding to the language production replaced by the string language.
b. If script is not undefined, then
i. If tag does not contain a script production, then
1. Set tag to the concatenation of the language production of tag, "-", script, and the rest of tag.
ii. Else,
1. Set tag to tag with the substring corresponding to the script production replaced by the string script.
c. If region is not undefined, then
i. If tag does not contain a region production, then
1. Set tag to the concatenation of the language production of tag, the substring corresponding to the "-" script production if present, "-", region, and the rest of tag.
ii. Else,
1. Set tag to tag with the substring corresponding to the region production replaced by the string region.
10. Return CanonicalizeLanguageTag(tag).
includes: [testIntl.js, compareArray.js]
features: [Intl.Locale]
---*/
// Intl.Locale step 11.a.
assert.throws(TypeError, function() { new Intl.Locale("en", null) })
// ApplyOptionsToTag step 2.
for (const invalidTag of getInvalidLanguageTags()) {
assert.throws(RangeError, function() {
new Intl.Locale(invalidTag)
}, "Language tag: " + invalidTag);
}
// ApplyOptionsToTag step 3, 9.a.i.
const validLanguageOptions = [
[undefined, "en"],
[null, "null"],
["zh-cmn", "cmn"],
["ZH-CMN", "cmn"],
["abcd", "abcd"],
["abcde", "abcde"],
["abcdef", "abcdef"],
["abcdefg", "abcdefg"],
["abcdefgh", "abcdefgh"],
[{ toString() { return "de" } }, "de"],
];
for (const [option, expected] of validLanguageOptions) {
assert.sameValue(new Intl.Locale("en", {
language: option,
}).toString(), expected);
}
// ApplyOptionsToTag step 4.a.
/*
language = 2*3ALPHA ; shortest ISO 639 code
["-" extlang] ; sometimes followed by
; extended language subtags
/ 4ALPHA ; or reserved for future use
/ 5*8ALPHA ; or registered language subtag
extlang = 3ALPHA ; selected ISO 639 codes
*2("-" 3ALPHA) ; permanently reserved
*/
const invalidLanguageOptions = [
"",
"a",
"ab7",
"notalanguage",
"undefined",
// Value contains more than just the 'language' production.
"fr-Latn",
"fr-FR",
"sa-vaidika",
"fr-a-asdf",
"fr-x-private",
// Irregular grandfathered language tag.
"i-klingon",
// Regular grandfathered language tag.
"zh-Hant",
// Reserved with extended language subtag
"abcd-US",
"abcde-US",
"abcdef-US",
"abcdefg-US",
"abcdefgh-US",
7,
];
for (const invalidLanguageOption of invalidLanguageOptions) {
assert.throws(RangeError, () => new Intl.Locale("en", {language: invalidLanguageOption}));
}
// ApplyOptionsToTag step 5, 9.b.
const validScriptOptions = [
[null, "en-Null"],
["bali", "en-Bali"],
["Bali", "en-Bali"],
["bALI", "en-BALI"], // TODO REVIEW: is this the correct case regularization?
[{ toString() { return "Brai" } }, "en-Brai"],
];
for (const [option, expected] of validScriptOptions) {
assert.sameValue(new Intl.Locale("en", {
script: option,
}).toString(), expected);
assert.sameValue(new Intl.Locale("en-Cyrl", {
script: option,
}).toString(), expected);
}
// ApplyOptionsToTag step 6.a.
/*
script = 4ALPHA ; ISO 15924 code
*/
const invalidScriptOptions = [
"",
"a",
"ab",
"abc",
"abc7",
"notascript",
"undefined",
"Bal\u0130",
"Bal\u0131",
// Value contains more than just the 'script' production.
"ary-Arab",
"Latn-SA",
"Latn-vaidika",
"Latn-a-asdf",
"Latn-x-private",
7,
];
for (const invalidScriptOption of invalidScriptOptions) {
assert.throws(RangeError, () => new Intl.Locale("en", {script: invalidScriptOption}));
}
// ApplyOptionsToTag step 7, 9.c.
const validRegionOptions = [
["FR", "en-FR"],
["554", "en-554"],
[554, "en-554"],
];
for (const [option, expected] of validRegionOptions) {
assert.sameValue(new Intl.Locale("en", {
region: option,
}).toString(), expected);
assert.sameValue(new Intl.Locale("en-US", {
region: option,
}).toString(), expected);
}
// ApplyOptionsToTag step 8.a.
/*
region = 2ALPHA ; ISO 3166-1 code
/ 3DIGIT ; UN M.49 code
*/
const invalidRegionOptions = [
"",
"a",
"abc",
"a7",
// Value cannot be parsed as a 'region' production.
"notaregion",
// Value contains more than just the 'region' production.
"SA-vaidika",
"SA-a-asdf",
"SA-x-private",
// Value contains more than just the 'script' production.
"ary-Arab",
"Latn-SA",
"Latn-vaidika",
"Latn-a-asdf",
"Latn-x-private",
7,
];
for (const invalidRegionOption of invalidRegionOptions) {
assert.throws(RangeError, () => new Intl.Locale("en", {region: invalidRegionOption}));
}
// Intl.Locale step 14.
const validCalendarOptions = [
["abc", "en-u-ca-abc"],
["abcd", "en-u-ca-abcd"],
["abcde", "en-u-ca-abcde"],
["abcdef", "en-u-ca-abcdef"],
["abcdefg", "en-u-ca-abcdefg"],
["abcdefgh", "en-u-ca-abcdefgh"],
["12345678", "en-u-ca-12345678"],
["1234abcd", "en-u-ca-1234abcd"],
["1234abcd-abc123", "en-u-ca-1234abcd-abc123"],
];
for (const [option, expected] of validCalendarOptions) {
assert.sameValue(new Intl.Locale("en", {
calendar: option,
}).toString(), expected);
assert.sameValue(new Intl.Locale("en-u-ca-gregory", {
calendar: option,
}).toString(), expected);
}
// Intl.Locale step 15.
/*
alphanum = (ALPHA / DIGIT) ; letters and numbers
calendar = (3*8alphanum) *("-" (3*8alphanum))
*/
const invalidCalendarOptions = [
"",
"a",
"ab",
"abcdefghi",
"abc-abcdefghi",
];
for (const invalidCalendarOption of invalidCalendarOptions) {
assert.throws(RangeError, () => new Intl.Locale("en", {calendar: invalidCalendarOption}));
}
// Copyright 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.locale
description: >
The value of the [[Prototype]] internal slot of the Intl.Locale constructor is the
intrinsic object %FunctionPrototype%.
features: [Intl.Locale]
---*/
assert.sameValue(
Object.getPrototypeOf(Intl.Locale),
Function.prototype,
"Object.getPrototypeOf(Intl.Locale) equals the value of Function.prototype"
);
...@@ -2,15 +2,19 @@ ...@@ -2,15 +2,19 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the properties of a Locale instance. Intl.Locale instance object extensibility
info: | info: |
Intl.Locale( tag [, options] ) 17 ECMAScript Standard Built-in Objects:
6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, %LocalePrototype%, internalSlotsList).
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
const value = new Intl.Locale("en"); assert.sameValue(
assert.sameValue(Object.getPrototypeOf(value), Intl.Locale.prototype); Object.isExtensible(new Intl.Locale('en')),
assert.sameValue(Object.isExtensible(value), true); true,
"Object.isExtensible(new Intl.Locale('en')) returns true"
);
// 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: >
Intl.Locale instance object created from %LocalePrototype%.
info: |
Intl.Locale( tag [, options] )
6. Let locale be ?
OrdinaryCreateFromConstructor(NewTarget, %LocalePrototype%,
internalSlotsList).
features: [Intl.Locale]
---*/
const value = new Intl.Locale('en');
assert.sameValue(
Object.getPrototypeOf(value),
Intl.Locale.prototype,
"Object.getPrototypeOf(value) equals the value of Intl.Locale.prototype"
);
...@@ -2,20 +2,19 @@ ...@@ -2,20 +2,19 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the type check on the tag argument to Intl.Locale. Verifies the type check on the tag argument to Intl.Locale.
info: | info: |
Intl.Locale( tag [, options] ) Intl.Locale( tag [, options] )
7. If Type(tag) is not String or Object, throw a TypeError exception.
7. If Type(tag) is not String or Object, throw a TypeError exception.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
const boolean_values = [ assert.throws(TypeError, function() {
true, new Intl.Locale(true);
false, }, "true is an invalid tag value");
]; assert.throws(TypeError, function() {
new Intl.Locale(false);
for (const boolean_value of boolean_values) { }, "false is an invalid tag value");
assert.throws(TypeError, () => new Intl.Locale(boolean_value));
}
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the type check on the tag argument to Intl.Locale. Verifies the type check on the tag argument to Intl.Locale.
info: | info: |
Intl.Locale( tag [, options] ) Intl.Locale( tag [, options] )
7. If Type(tag) is not String or Object, throw a TypeError exception.
7. If Type(tag) is not String or Object, throw a TypeError exception.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
assert.throws(TypeError, () => new Intl.Locale(null)); assert.throws(TypeError, function() {
new Intl.Locale(null);
}, "null is an invalid tag value");
...@@ -2,19 +2,29 @@ ...@@ -2,19 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the type check on the tag argument to Intl.Locale. Verifies the type check on the tag argument to Intl.Locale.
info: | info: |
Intl.Locale( tag [, options] ) Intl.Locale( tag [, options] )
7. If Type(tag) is not String or Object, throw a TypeError exception. 7. If Type(tag) is not String or Object, throw a TypeError exception.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
const invalid_type_values = [ assert.throws(TypeError, function() {
0, 1.5, Infinity, -Infinity, NaN, new Intl.Locale(0);
]; }, "0 is an invalid tag value");
assert.throws(TypeError, function() {
new Intl.Locale(1);
}, "1 is an invalid tag value");
assert.throws(TypeError, function() {
new Intl.Locale(Infinity);
}, "Infinity is an invalid tag value");
assert.throws(TypeError, function() {
new Intl.Locale(NaN);
}, "NaN is an invalid tag value");
for (const invalid_type_value of invalid_type_values) {
assert.throws(TypeError, () => new Intl.Locale(invalid_type_value));
}
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the type check on the tag argument to Intl.Locale. Verifies the type check on the tag argument to Intl.Locale.
info: | info: |
Intl.Locale( tag [, options] ) Intl.Locale( tag [, options] )
7. If Type(tag) is not String or Object, throw a TypeError exception. 7. If Type(tag) is not String or Object, throw a TypeError exception.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
const symbol = Symbol(); assert.throws(TypeError, function() {
assert.throws(TypeError, () => new Intl.Locale(symbol)); new Intl.Locale(Symbol());
}, "Symbol() is an invalid tag value");
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Verifies the type check on the tag argument to Intl.Locale. Verifies the type check on the tag argument to Intl.Locale.
info: | info: |
Intl.Locale( tag [, options] ) Intl.Locale( tag [, options] )
7. If Type(tag) is not String or Object, throw a TypeError exception. 7. If Type(tag) is not String or Object, throw a TypeError exception.
features: [Intl.Locale] features: [Intl.Locale]
---*/ ---*/
assert.throws(TypeError, () => new Intl.Locale()); assert.throws(TypeError, function() {
assert.throws(TypeError, () => new Intl.Locale(undefined)); new Intl.Locale();
}, "(empty) is an invalid tag value");
assert.throws(TypeError, function() {
new Intl.Locale(undefined)
}, "undefined is an invalid tag value");
// 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: |
Intl.Locale( tag [, options] )
...
11. Else
a. Let options be ? ToObject(options).
12. Set tag to ? ApplyOptionsToTag(tag, options).
...
ApplyOptionsToTag( tag, options )
...
2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
...
includes: [testIntl.js]
features: [Intl.Locale]
---*/
// Intl.Locale step 11.a.
assert.throws(TypeError, function() { new Intl.Locale("en", null) })
// ApplyOptionsToTag step 2.
for (const invalidTag of getInvalidLanguageTags()) {
assert.throws(RangeError, function() {
new Intl.Locale(invalidTag);
}, `${invalidTag} is an invalid tag value`);
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: pending esid: sec-intl.locale
description: > description: >
Checks the "length" property of the Locale constructor. Checks the "length" property of the Locale constructor.
info: | info: |
...@@ -10,11 +10,13 @@ info: | ...@@ -10,11 +10,13 @@ info: |
The Locale constructor is a standard built-in property of the Intl object. 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. 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 }. 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] features: [Intl.Locale]
---*/ ---*/
const propdesc = Object.getOwnPropertyDescriptor(Intl.Locale, "length"); verifyProperty(Intl.Locale, "length", {
assert.sameValue(propdesc.writable, false); value: 1,
assert.sameValue(propdesc.enumerable, false); writable: false,
assert.sameValue(propdesc.configurable, true); enumerable: false,
assert.sameValue(propdesc.value, 1); configurable: true
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment