test262/test/intl402/NumberFormat/throws-for-maximumFractionDigits-over-limit.js
Frank Yung-Fong Tang 92a9eca159
Add tests for ECMA402 PR 786 (#3875)
https://github.com/tc39/ecma402/pull/786

This ECMA402 PR 786 reached TC39 consensus in the July 2023 meeting
2023-07-24 17:47:19 +02:00

23 lines
838 B
JavaScript

// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-initializenumberformat
description: >
Tests that the options maximumFractionDigits limit to the range 0 - 100.
info: |
InitializeNumberFormat ( numberFormat, locales, options )
25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).
DefaultNumberOption ( value, minimum, maximum, fallback )
3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
---*/
let wontThrow = new Intl.NumberFormat(undefined, {maximumFractionDigits: 100});
assert.throws(RangeError, function () {
return new Intl.NumberFormat(undefined, {maximumFractionDigits: 101});
}, "Throws RangeError when maximumFractionDigits is more than 100.");