Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Date/value-get-symbol-to-prim-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: >
7 Behavior when error thrown while accessing `Symbol.toPrimitive` property
8 info: |
9 [...]
10 3. If NewTarget is not undefined, then
11 a. If Type(value) is Object and value has a [[DateValue]] internal slot,
12 then
13 [...]
14 b. Else,
15 i. Let v be ? ToPrimitive(value).
16
17 ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] )
18
19 [...]
20 4. Let exoticToPrim be GetMethod(input, @@toPrimitive).
21 5. ReturnIfAbrupt(exoticToPrim).
22 features: [Symbol.toPrimitive]
23 ---*/
24
25 var y = Object.defineProperty({}, Symbol.toPrimitive, {
26 get: function() {
27 throw new Test262Error();
28 }
29 });
30
31 assert.throws(Test262Error, function() {
32 new Date(y);
33 });