value-symbol-to-prim-err.js (1003B)
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 description: > 6 Behavior when error thrown by invocation of `Symbol.toPrimitive` method 7 during coercion 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 6. If exoticToPrim is not undefined, then 23 a. Let result be Call(exoticToPrim, input, «hint»). 24 b. ReturnIfAbrupt(result). 25 features: [Symbol.toPrimitive] 26 ---*/ 27 28 var y = {}; 29 y[Symbol.toPrimitive] = function() { 30 throw new Test262Error(); 31 }; 32 33 assert.throws(Test262Error, function() { 34 new Date(y); 35 }); 36 37 reportCompare(0, 0);