Debian Codegraph @

js/src/tests/test262/intl402/DateTimeFormat/constructor-options-dateStyle-invalid.js

raw
1 // Copyright 2019 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-createdatetimeformat
6 description: >
7 Checks error cases for the options argument to the DateTimeFormat constructor.
8 info: |
9 CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults )
10
11 ...
12 39. Let dateStyle be ? GetOption(options, "dateStyle", "string", « "full", "long", "medium", "short" », undefined).
13 features: [Intl.DateTimeFormat-datetimestyle]
14 ---*/
15
16
17 const invalidOptions = [
18 "",
19 "FULL",
20 " long",
21 "short ",
22 "narrow",
23 "numeric",
24 ];
25 for (const dateStyle of invalidOptions) {
26 assert.throws(RangeError, function() {
27 new Intl.DateTimeFormat("en", { dateStyle });
28 }, `new Intl.DateTimeFormat("en", { dateStyle: "${dateStyle}" }) throws RangeError`);
29 }
30
31 reportCompare(0, 0);