mirror of https://github.com/tc39/test262.git
29 lines
781 B
JavaScript
29 lines
781 B
JavaScript
// Copyright 2019 Google Inc. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-createdatetimeformat
|
|
description: >
|
|
Checks error cases for the options argument to the DateTimeFormat constructor.
|
|
info: |
|
|
[[DayPeriod]] `"dayPeriod"` `"narrow"`, `"short"`, `"long"`
|
|
CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults )
|
|
|
|
...
|
|
features: [Intl.DateTimeFormat-dayPeriod]
|
|
---*/
|
|
|
|
const invalidOptions = [
|
|
"",
|
|
"LONG",
|
|
" long",
|
|
"short ",
|
|
"full",
|
|
"numeric",
|
|
];
|
|
for (const dayPeriod of invalidOptions) {
|
|
assert.throws(RangeError, function() {
|
|
new Intl.DateTimeFormat("en", { dayPeriod });
|
|
}, `new Intl.DateTimeFormat("en", { dayPeriod: "${dayPeriod}" }) throws RangeError`);
|
|
}
|