| 1 |
// Copyright 2023 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 |
Verifies that constructor throws when dateStyle is combined with explicit format components. |
| 8 |
info: | |
| 9 |
CreateDateTimeFormat ( newTarget, locales, options, required, defaults ) |
| 10 |
... |
| 11 |
39. Let dateStyle be ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined). |
| 12 |
40. Set dateTimeFormat.[[DateStyle]] to dateStyle. |
| 13 |
41. Let timeStyle be ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined). |
| 14 |
42. Set dateTimeFormat.[[TimeStyle]] to timeStyle. |
| 15 |
43. If dateStyle is not undefined or timeStyle is not undefined, then |
| 16 |
|
| 17 |
a. If hasExplicitFormatComponents is true, then |
| 18 |
i. Throw a TypeError exception. |
| 19 |
---*/ |
| 20 |
|
| 21 |
function optionsThrow(options, testName) { |
| 22 |
assert.throws(TypeError, function() { |
| 23 |
new Intl.DateTimeFormat(undefined, options); |
| 24 |
}, testName + ":"); |
| 25 |
} |
| 26 |
|
| 27 |
optionsThrow({dateStyle: "full", weekday: "long"}, "dateStyle-weekday"); |
| 28 |
optionsThrow({dateStyle: "full", era: "long"}, "dateStyle-era"); |
| 29 |
optionsThrow({dateStyle: "full", year: "numeric"}, "dateStyle-year"); |
| 30 |
optionsThrow({dateStyle: "full", month: "numeric"}, "dateStyle-month"); |
| 31 |
optionsThrow({dateStyle: "full", day: "numeric"}, "dateStyle-day"); |
| 32 |
optionsThrow({dateStyle: "full", dayPeriod: "long"}, "dateStyle-dayPeriod"); |
| 33 |
optionsThrow({dateStyle: "full", hour: "numeric"}, "dateStyle-hour"); |
| 34 |
optionsThrow({dateStyle: "full", minute: "numeric"}, "dateStyle-minute"); |
| 35 |
optionsThrow({dateStyle: "full", second: "numeric"}, "dateStyle-second"); |
| 36 |
optionsThrow({dateStyle: "full", fractionalSecondDigits: 1}, "dateStyle-fractionalSecondDigits"); |
| 37 |
optionsThrow({dateStyle: "full", timeZoneName: "short"}, "dateStyle-timeZoneName"); |
| 38 |
|
| 39 |
optionsThrow({timeStyle: "full", weekday: "long"}, "timeStyle-weekday"); |
| 40 |
optionsThrow({timeStyle: "full", era: "long"}, "timeStyle-era"); |
| 41 |
optionsThrow({timeStyle: "full", year: "numeric"}, "timeStyle-year"); |
| 42 |
optionsThrow({timeStyle: "full", month: "numeric"}, "timeStyle-month"); |
| 43 |
optionsThrow({timeStyle: "full", day: "numeric"}, "timeStyle-day"); |
| 44 |
optionsThrow({timeStyle: "full", dayPeriod: "long"}, "timeStyle-dayPeriod"); |
| 45 |
optionsThrow({timeStyle: "full", hour: "numeric"}, "timeStyle-hour"); |
| 46 |
optionsThrow({timeStyle: "full", minute: "numeric"}, "timeStyle-minute"); |
| 47 |
optionsThrow({timeStyle: "full", second: "numeric"}, "timeStyle-second"); |
| 48 |
optionsThrow({timeStyle: "full", fractionalSecondDigits: 1}, "timeStyle-fractionalSecondDigits"); |
| 49 |
optionsThrow({timeStyle: "full", timeZoneName: "short"}, "timeStyle-timeZoneName"); |
| 50 |
|
| 51 |
reportCompare(0, 0); |