Debian Codegraph @

js/src/tests/test262/intl402/DurationFormat/constructor-options-fractionalDigits-invalid.js

raw
1 // |reftest| skip-if(!Intl.hasOwnProperty('DurationFormat')) -- Intl.DurationFormat is not enabled unconditionally
2 // Copyright 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-Intl.DurationFormat
7 description: Tests that the option fractionalDigits is processed correctly.
8 info: |
9 Intl.DurationFormat ( [ locales [ , options ] ] )
10 (...)
11 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined).
12 features: [Intl.DurationFormat]
13 ---*/
14
15 const invalidOptions = [
16 -10,
17 10
18 ];
19
20 for (const fractionalDigits of invalidOptions) {
21 assert.throws(RangeError, function() {
22 new Intl.DurationFormat("en", { fractionalDigits });
23 }, `new Intl.DurationFormat("en", {fractionalDigits: "${fractionalDigits}"}) throws RangeError`);
24 }
25
26 reportCompare(0, 0);