diff --git a/test/intl402/NumberFormat/constructor-order.js b/test/intl402/NumberFormat/constructor-order.js index 173ad796b8..4cf1690345 100644 --- a/test/intl402/NumberFormat/constructor-order.js +++ b/test/intl402/NumberFormat/constructor-order.js @@ -10,17 +10,16 @@ info: | 5. Let currency be ? GetOption(options, "currency", "string", undefined, undefined). 6. If currency is not undefined, then a. If the result of IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception. - 9. Let unit be ? GetOption(options, "unit", "string", undefined, undefined). - 10. If unit is not undefined, then + 7. If style is "currency" and currency is undefined, throw a TypeError exception. + ... + 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. - 12. If style is "currency", then - a. If currency is undefined, throw a TypeError exception. - 13. If style is "unit", then - a. If unit is undefined, throw a TypeError exception. + 12. If style is "unit" and unit is undefined, throw a TypeError exception. features: [Intl.NumberFormat-unified] ---*/ -assert.throws(RangeError, () => { +assert.throws(TypeError, () => { new Intl.NumberFormat([], { style: "currency", unit: "test" }) }); diff --git a/test/intl402/NumberFormat/constructor-unit.js b/test/intl402/NumberFormat/constructor-unit.js index c3123c9250..ec83aca9be 100644 --- a/test/intl402/NumberFormat/constructor-unit.js +++ b/test/intl402/NumberFormat/constructor-unit.js @@ -14,11 +14,24 @@ assert.throws(TypeError, () => { }); 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, () => { new Intl.NumberFormat([], { style, 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([], {