tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

coerce-symbol-to-prim-err.js (1097B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 es6id: 12.10.3
      5 description: >
      6    Behavior when error thrown by invocation of `Symbol.toPrimitive` method
      7    during coercion
      8 info: |
      9    [...]
     10    7. Return the result of performing Abstract Equality Comparison rval ==
     11       lval.
     12 
     13    ES6 Section 7.2.12 Abstract Equality Comparison
     14 
     15    [...]
     16    10. If Type(x) is either String, Number, or Symbol and Type(y) is Object,
     17        then return the result of the comparison x == ToPrimitive(y).
     18 
     19    ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] )
     20 
     21    [...]
     22    4. Let exoticToPrim be GetMethod(input, @@toPrimitive).
     23    5. ReturnIfAbrupt(exoticToPrim).
     24    6. If exoticToPrim is not undefined, then
     25       a. Let result be Call(exoticToPrim, input, «hint»).
     26       b. ReturnIfAbrupt(result).
     27 features: [Symbol.toPrimitive]
     28 ---*/
     29 
     30 var y = {};
     31 y[Symbol.toPrimitive] = function() {
     32  throw new Test262Error();
     33 };
     34 
     35 assert.throws(Test262Error, function() {
     36  0 == y;
     37 });
     38 
     39 reportCompare(0, 0);