Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Date/value-to-primitive-call-err.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-date-value
5 es6id: 20.3.2.2
6 description: Error invoking `Symbol.toPrimitive` method of object value
7 info: |
8 3. If NewTarget is not undefined, then
9 a. If Type(value) is Object and value has a [[DateValue]] internal slot, then
10 i. Let tv be thisTimeValue(value).
11 b. Else,
12 i. Let v be ? ToPrimitive(value).
13
14 ToPrimitive ( input [ , PreferredType ] )
15
16 [...]
17 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive).
18 features: [Symbol.toPrimitive]
19 ---*/
20
21 var badToPrimitive = {};
22 badToPrimitive[Symbol.toPrimitive] = function() {
23 throw new Test262Error();
24 };
25
26 assert.throws(Test262Error, function() {
27 new Date(badToPrimitive);
28 });