mirror of
https://github.com/tc39/test262.git
synced 2025-07-31 01:44:54 +02:00
Intl: Add tests for throwing getters in options objects.
This commit is contained in:
parent
12055caa1c
commit
9271068a83
@ -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-initializecollator
|
||||||
|
description: Checks the propagation of exceptions from the options for the Collator constructor.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"usage",
|
||||||
|
"localeMatcher",
|
||||||
|
"numeric",
|
||||||
|
"caseFirst",
|
||||||
|
"sensitivity",
|
||||||
|
"ignorePunctuation",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.Collator("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializedatetimeformat
|
||||||
|
description: Checks the propagation of exceptions from the options for the DateTimeFormat constructor.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"weekday", "year", "month", "day",
|
||||||
|
"hour", "minute", "second",
|
||||||
|
"localeMatcher",
|
||||||
|
"hour12",
|
||||||
|
"hourCycle",
|
||||||
|
"timeZone",
|
||||||
|
"era",
|
||||||
|
"timeZoneName",
|
||||||
|
"formatMatcher",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.DateTimeFormat("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-Intl.ListFormat
|
||||||
|
description: Checks the propagation of exceptions from the options for the ListFormat constructor.
|
||||||
|
features: [Intl.ListFormat]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"type",
|
||||||
|
"style",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.ListFormat("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
32
test/intl402/Locale/constructor-options-throwing-getters.js
Normal file
32
test/intl402/Locale/constructor-options-throwing-getters.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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 propagation of exceptions from the options for the Locale constructor.
|
||||||
|
features: [Intl.Locale]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"language",
|
||||||
|
"script",
|
||||||
|
"region",
|
||||||
|
"calendar",
|
||||||
|
"collation",
|
||||||
|
"hourCycle",
|
||||||
|
"caseFirst",
|
||||||
|
"numeric",
|
||||||
|
"numberingSystem",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.Locale("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializenumberformat
|
||||||
|
description: Checks the propagation of exceptions from the options for the NumberFormat constructor.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"localeMatcher",
|
||||||
|
"style",
|
||||||
|
"currency",
|
||||||
|
"currencyDisplay",
|
||||||
|
"minimumIntegerDigits",
|
||||||
|
"minimumFractionDigits",
|
||||||
|
"maximumFractionDigits",
|
||||||
|
"minimumSignificantDigits",
|
||||||
|
"maximumSignificantDigits",
|
||||||
|
"useGrouping",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.NumberFormat("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializepluralrules
|
||||||
|
description: Checks the propagation of exceptions from the options for the NumberFormat constructor.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"localeMatcher",
|
||||||
|
"type",
|
||||||
|
"minimumIntegerDigits",
|
||||||
|
"minimumFractionDigits",
|
||||||
|
"maximumFractionDigits",
|
||||||
|
"minimumSignificantDigits",
|
||||||
|
"maximumSignificantDigits",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.PluralRules("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright 2018 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-InitializeRelativeTimeFormat
|
||||||
|
description: Checks the propagation of exceptions from the options for the RelativeTimeFormat constructor.
|
||||||
|
features: [Intl.RelativeTimeFormat]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function CustomError() {}
|
||||||
|
|
||||||
|
const options = [
|
||||||
|
"localeMatcher",
|
||||||
|
"style",
|
||||||
|
"numeric",
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const option of options) {
|
||||||
|
assert.throws(CustomError, () => {
|
||||||
|
new Intl.RelativeTimeFormat("en", {
|
||||||
|
get [option]() {
|
||||||
|
throw new CustomError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, `Exception from ${option} getter should be propagated`);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user