summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-datetimefield-invalid.js
blob: b1532a389c5cbb01c472d53e1008ff90f73692a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.DisplayNames.prototype.of
description: Throws a RangeError for invalid `dateTimeField` codes
features: [Intl.DisplayNames-v2]
---*/

var displayNames = new Intl.DisplayNames(undefined, {type: 'dateTimeField'});

assert.throws(RangeError, function() {
  displayNames.of('');
}, 'empty string');

assert.throws(RangeError, function() {
  displayNames.of('timezoneName');
}, 'timezoneName');

assert.throws(RangeError, function() {
  displayNames.of('timezonename');
}, 'timezonename');

assert.throws(RangeError, function() {
  displayNames.of('millisecond');
}, 'millisecond');

assert.throws(RangeError, function() {
  displayNames.of('seconds');
}, 'seconds');

assert.throws(RangeError, function() {
  displayNames.of(' year');
}, 'year (with leading space)');

assert.throws(RangeError, function() {
  displayNames.of('year ');
}, 'year (with trailing space)');

reportCompare(0, 0);