throws-for-maximumFractionDigits-under-limit.js (855B)
1 // Copyright 2023 Google Inc. 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: > 7 Tests that the options maximumFractionDigits limit to the range 0 - 100. 8 info: | 9 InitializeNumberFormat ( numberFormat, locales, options ) 10 11 25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined). 12 13 DefaultNumberOption ( value, minimum, maximum, fallback ) 14 15 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception. 16 ---*/ 17 18 let wontThrow = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0}); 19 20 assert.throws(RangeError, function () { 21 return new Intl.NumberFormat(undefined, {maximumFractionDigits: -1}); 22 }, "Throws RangeError when maximumFractionDigits is less than 0."); 23 24 reportCompare(0, 0);