Debian Codegraph @

js/src/tests/test262/intl402/DurationFormat/constructor-options-style-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: Checks handling of invalid value for the style option to the DurationFormat constructor.
8 info: |
9 InitializeDurationFormat (DurationFormat, locales, options)
10 (...)
11 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long").
12 14. Set durationFormat.[[Style]] to style.
13 features: [Intl.DurationFormat]
14 ---*/
15
16 const invalidOptions = [
17 null,
18 1,
19 "",
20 "Long",
21 "LONG",
22 "long\0",
23 "Short",
24 "SHORT",
25 "short\0",
26 "Narrow",
27 "NARROW",
28 "narrow\0",
29 "Digital",
30 "DIGITAL",
31 "digital\0",
32 ];
33
34 for (const invalidOption of invalidOptions) {
35 assert.throws(RangeError, function() {
36 new Intl.DurationFormat([], {"style": invalidOption});
37 }, `${invalidOption} is an invalid style option value`);
38 }
39
40 reportCompare(0, 0);