| 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 by invocation of `Symbol.toPrimitive` method |
| 8 |
during coercion |
| 9 |
info: | |
| 10 |
[...] |
| 11 |
3. If NewTarget is not undefined, then |
| 12 |
a. If Type(value) is Object and value has a [[DateValue]] internal slot, |
| 13 |
then |
| 14 |
[...] |
| 15 |
b. Else, |
| 16 |
i. Let v be ? ToPrimitive(value). |
| 17 |
|
| 18 |
ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] ) |
| 19 |
|
| 20 |
[...] |
| 21 |
4. Let exoticToPrim be GetMethod(input, @@toPrimitive). |
| 22 |
5. ReturnIfAbrupt(exoticToPrim). |
| 23 |
6. If exoticToPrim is not undefined, then |
| 24 |
a. Let result be Call(exoticToPrim, input, «hint»). |
| 25 |
b. ReturnIfAbrupt(result). |
| 26 |
features: [Symbol.toPrimitive] |
| 27 |
---*/ |
| 28 |
|
| 29 |
var y = {}; |
| 30 |
y[Symbol.toPrimitive] = function() { |
| 31 |
throw new Test262Error(); |
| 32 |
}; |
| 33 |
|
| 34 |
assert.throws(Test262Error, function() { |
| 35 |
new Date(y); |
| 36 |
}); |