summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRangeToParts/date-is-infinity-throws.js
blob: 9074bc63f01362b08dfa5814769cbd56f595c0ae (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2019 Google, Inc.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
  Throws a RangeError if date arg is cast to an Infinity value
info: |
  Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )

  1. Let dtf be this value.
  2. If Type(dtf) is not Object, throw a TypeError exception.
  3. If dtf does not have an [[InitializedDateTimeFormat]] internal slot, throw a TypeError exception.
  4. If startDate is undefined or endDate is undefined, throw a RangeError exception.
  5. Let x be ? ToNumber(startDate).
  6. Let y be ? ToNumber(endDate).
  7. If x is greater than y, throw a RangeError exception.
  8. Return ? FormatDateTimeRangeToParts(dtf, x, y).

  FormatDateTimeRangeToParts ( dateTimeFormat, x, y )

  1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).

  PartitionDateTimeRangePattern ( dateTimeFormat, x, y )
  1. Let x be TimeClip(x).
  2. If x is NaN, throw a RangeError exception.
  3. Let y be TimeClip(y).
  4. If y is NaN, throw a RangeError exception.

  TimeClip ( time )
  1. If time is not finite, return NaN.

features: [Intl.DateTimeFormat-formatRange]
---*/

var dtf = new Intl.DateTimeFormat();

var date = new Date();

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(Infinity, date);
}, "+Infinity/date");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(-Infinity, date);
}, "-Infinity/date");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(date, Infinity);
}, "date/+Infinity");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(date, -Infinity);
}, "date/-Infinity");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(Infinity, Infinity);
}, "+Infinity/+Infinity");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(-Infinity, -Infinity);
}, "-Infinity/-Infinity");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(Infinity, -Infinity);
}, "+Infinity/-Infinity");

assert.throws(RangeError, function() {
  dtf.formatRangeToParts(-Infinity, Infinity);
}, "-Infinity/+Infinity");

reportCompare(0, 0);