mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 08:24:23 +02:00
Updated expected error in NumberFormat constructor per current spec
This commit is contained in:
parent
d42aaa4b15
commit
630f7dee66
@ -10,17 +10,16 @@ info: |
|
|||||||
5. Let currency be ? GetOption(options, "currency", "string", undefined, undefined).
|
5. Let currency be ? GetOption(options, "currency", "string", undefined, undefined).
|
||||||
6. If currency is not undefined, then
|
6. If currency is not undefined, then
|
||||||
a. If the result of IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception.
|
a. If the result of IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception.
|
||||||
9. Let unit be ? GetOption(options, "unit", "string", undefined, undefined).
|
7. If style is "currency" and currency is undefined, throw a TypeError exception.
|
||||||
10. If unit is not undefined, then
|
...
|
||||||
|
10. Let unit be ? GetOption(options, "unit", "string", undefined, undefined).
|
||||||
|
11. If unit is not undefined, then
|
||||||
a. If the result of IsWellFormedUnitIdentifier(unit) is false, throw a RangeError exception.
|
a. If the result of IsWellFormedUnitIdentifier(unit) is false, throw a RangeError exception.
|
||||||
12. If style is "currency", then
|
12. If style is "unit" and unit is undefined, throw a TypeError exception.
|
||||||
a. If currency is undefined, throw a TypeError exception.
|
|
||||||
13. If style is "unit", then
|
|
||||||
a. If unit is undefined, throw a TypeError exception.
|
|
||||||
features: [Intl.NumberFormat-unified]
|
features: [Intl.NumberFormat-unified]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.throws(RangeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
new Intl.NumberFormat([], { style: "currency", unit: "test" })
|
new Intl.NumberFormat([], { style: "currency", unit: "test" })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,11 +14,24 @@ assert.throws(TypeError, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const unit of ["test", "MILE", "kB"]) {
|
for (const unit of ["test", "MILE", "kB"]) {
|
||||||
for (const style of [undefined, "decimal", "currency", "unit"]) {
|
// Throws RangeError for invalid unit identifier.
|
||||||
|
for (const style of [undefined, "decimal", "unit"]) {
|
||||||
assert.throws(RangeError, () => {
|
assert.throws(RangeError, () => {
|
||||||
new Intl.NumberFormat([], { style, unit })
|
new Intl.NumberFormat([], { style, unit })
|
||||||
}, `{ style: ${style}, unit: ${unit} }`);
|
}, `{ style: ${style}, unit: ${unit} }`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const style = "currency";
|
||||||
|
|
||||||
|
// Throws TypeError because "currency" option is missing.
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
new Intl.NumberFormat([], { style, unit })
|
||||||
|
}, `{ style: ${style}, unit: ${unit} }`);
|
||||||
|
|
||||||
|
// Throws RangeError for invalid unit identifier.
|
||||||
|
assert.throws(RangeError, () => {
|
||||||
|
new Intl.NumberFormat([], { style, unit, currency: "USD" })
|
||||||
|
}, `{ style: ${style}, unit: ${unit} }`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nf = new Intl.NumberFormat([], {
|
const nf = new Intl.NumberFormat([], {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user