constructor-order.js (1199B)
1 // Copyright 2019 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-initializenumberformat 6 description: Checks handling of the unit option with the currency style. 7 info: | 8 SetNumberFormatUnitOptions ( intlObj, options ) 9 10 5. Let currency be ? GetOption(options, "currency", "string", undefined, undefined). 11 6. If currency is not undefined, then 12 a. If the result of IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception. 13 7. If style is "currency" and currency is undefined, throw a TypeError exception. 14 ... 15 10. Let unit be ? GetOption(options, "unit", "string", undefined, undefined). 16 11. If unit is not undefined, then 17 a. If the result of IsWellFormedUnitIdentifier(unit) is false, throw a RangeError exception. 18 12. If style is "unit" and unit is undefined, throw a TypeError exception. 19 features: [Intl.NumberFormat-unified] 20 ---*/ 21 22 assert.throws(TypeError, () => { 23 new Intl.NumberFormat([], { style: "currency", unit: "test" }) 24 }); 25 26 assert.throws(RangeError, () => { 27 new Intl.NumberFormat([], { style: "unit", currency: "test" }) 28 }); 29 30 reportCompare(0, 0);