Debian Codegraph @

js/src/tests/test262/intl402/NumberFormat/constructor-roundingIncrement-invalid.js

raw
1 // Copyright 2021 the V8 project authors. All rights reserved.
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-initializenumberformat
6 description: Rejects invalid values for roundingIncrement option.
7 features: [Intl.NumberFormat-v3]
8 ---*/
9
10 assert.throws(RangeError, function() {
11 new Intl.NumberFormat([], {roundingIncrement: 0});
12 }, '0');
13
14 assert.throws(RangeError, function() {
15 new Intl.NumberFormat([], {roundingIncrement: 3});
16 }, '3');
17
18 assert.throws(RangeError, function() {
19 new Intl.NumberFormat([], {roundingIncrement: 4});
20 }, '4');
21
22 assert.throws(RangeError, function() {
23 new Intl.NumberFormat([], {roundingIncrement: 5000.1});
24 }, '5000.1');
25
26 assert.throws(RangeError, function() {
27 new Intl.NumberFormat([], {roundingIncrement: 5001});
28 }, '5001');
29
30 assert.throws(TypeError, function() {
31 new Intl.NumberFormat([], {roundingIncrement: 2, roundingPriority: 'morePrecision'});
32 }, '2, roundingType is "morePrecision"');
33
34 assert.throws(TypeError, function() {
35 new Intl.NumberFormat([], {roundingIncrement: 2, roundingPriority: 'lessPrecision'});
36 }, '2, roundingType is "lessPrecision"');
37
38 assert.throws(TypeError, function() {
39 new Intl.NumberFormat([], {roundingIncrement: 2, minimumSignificantDigits: 1});
40 }, '2, roundingType is "significantDigits"');
41
42 assert.throws(RangeError, function() {
43 new Intl.NumberFormat([], {roundingIncrement: 2, maximumFractionDigits:3 , minimumFractionDigits:2 });
44 }, '"maximumFractionDigits" is not equal to "minimumFractionDigits"');
45
46 reportCompare(0, 0);