summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatRange/argument-tonumber-throws.js
blob: ddbe0ed2fee39f0e5217082070ed08beb73fbb7e (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
// Copyright 2019 Igalia S.L. All rights reserved.
// This code is governed by the license found in the LICENSE file.

/*---
description: >
  Return abrupt completions from ToNumber(date)
info: |
  Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )

  5. Let x be ? ToNumber(startDate).
  6. Let y be ? ToNumber(endDate).
features: [Symbol,Intl.DateTimeFormat-formatRange]
---*/

const date = Date.now();

const objectValueOf = {
  valueOf: function() {
    throw new Test262Error();
  }
};

const objectToString = {
  toString: function() {
    throw new Test262Error();
  }
};

const dtf = new Intl.DateTimeFormat(["pt-BR"]);

assert.throws(Test262Error, function() {
  dtf.formatRange(objectValueOf, date);
}, "valueOf start");

assert.throws(Test262Error, function() {
  dtf.formatRange(date, objectValueOf);
}, "valueOf end");

assert.throws(Test262Error, function() {
  dtf.formatRange(objectToString, date);
}, "toString start");

assert.throws(Test262Error, function() {
  dtf.formatRange(date, objectToString);
}, "toString end");

const s = Symbol('1');
assert.throws(TypeError, function() {
  dtf.formatRange(s, date);
}, "symbol start");

assert.throws(TypeError, function() {
  dtf.formatRange(date, s);
}, "symbol end");

reportCompare(0, 0);