tor-browser

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

bigint-wrapped-values.js (1750B)


      1 // Copyright (C) 2017 Josh Wolfe. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 description: unsigned-right-shift operator ToNumeric with BigInt operands
      5 esid: sec-unsigned-right-shift-operator-runtime-semantics-evaluation
      6 info: After ToNumeric type coercion, unsigned-right-shift always throws for BigInt operands
      7 features: [BigInt, Symbol.toPrimitive, computed-property-names]
      8 ---*/
      9 assert.throws(TypeError, function() {
     10  Object(2n) >>> 0n;
     11 }, 'Object(2n) >>> 0n throws TypeError');
     12 
     13 assert.throws(TypeError, function() {
     14  0n >>> Object(2n);
     15 }, '0n >>> Object(2n) throws TypeError');
     16 
     17 assert.throws(TypeError, function() {
     18  ({
     19    [Symbol.toPrimitive]: function() {
     20      return 2n;
     21    }
     22  }) >>> 0n;
     23 }, '({[Symbol.toPrimitive]: function() {return 2n;}}) >>> 0n throws TypeError');
     24 
     25 assert.throws(TypeError, function() {
     26  0n >>> {
     27    [Symbol.toPrimitive]: function() {
     28      return 2n;
     29    }
     30  };
     31 }, '0n >>> {[Symbol.toPrimitive]: function() {return 2n;}} throws TypeError');
     32 
     33 assert.throws(TypeError, function() {
     34  ({
     35    valueOf: function() {
     36      return 2n;
     37    }
     38  }) >>> 0n;
     39 }, '({valueOf: function() {return 2n;}}) >>> 0n throws TypeError');
     40 
     41 assert.throws(TypeError, function() {
     42  0n >>> {
     43    valueOf: function() {
     44      return 2n;
     45    }
     46  };
     47 }, '0n >>> {valueOf: function() {return 2n;}} throws TypeError');
     48 
     49 assert.throws(TypeError, function() {
     50  ({
     51    toString: function() {
     52      return 2n;
     53    }
     54  }) >>> 0n;
     55 }, '({toString: function() {return 2n;}}) >>> 0n throws TypeError');
     56 
     57 assert.throws(TypeError, function() {
     58  0n >>> {
     59    toString: function() {
     60      return 2n;
     61    }
     62  };
     63 }, '0n >>> {toString: function() {return 2n;}} throws TypeError');
     64 
     65 reportCompare(0, 0);