tor-browser

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

bigint-wrapped-values.js (1424B)


      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: multiplication operator ToNumeric with BigInt operands
      5 esid: sec-multiplicative-operators-runtime-semantics-evaluation
      6 features: [BigInt, Symbol.toPrimitive, computed-property-names]
      7 ---*/
      8 assert.sameValue(Object(2n) * 2n, 4n, 'The result of (Object(2n) * 2n) is 4n');
      9 assert.sameValue(2n * Object(2n), 4n, 'The result of (2n * Object(2n)) is 4n');
     10 
     11 assert.sameValue({
     12  [Symbol.toPrimitive]: function() {
     13    return 2n;
     14  }
     15 } * 2n, 4n, 'The result of (({[Symbol.toPrimitive]: function() {return 2n;}}) * 2n) is 4n');
     16 
     17 assert.sameValue(2n * {
     18  [Symbol.toPrimitive]: function() {
     19    return 2n;
     20  }
     21 }, 4n, 'The result of (2n * {[Symbol.toPrimitive]: function() {return 2n;}}) is 4n');
     22 
     23 assert.sameValue({
     24  valueOf: function() {
     25    return 2n;
     26  }
     27 } * 2n, 4n, 'The result of (({valueOf: function() {return 2n;}}) * 2n) is 4n');
     28 
     29 assert.sameValue(2n * {
     30  valueOf: function() {
     31    return 2n;
     32  }
     33 }, 4n, 'The result of (2n * {valueOf: function() {return 2n;}}) is 4n');
     34 
     35 assert.sameValue({
     36  toString: function() {
     37    return 2n;
     38  }
     39 } * 2n, 4n, 'The result of (({toString: function() {return 2n;}}) * 2n) is 4n');
     40 
     41 assert.sameValue(2n * {
     42  toString: function() {
     43    return 2n;
     44  }
     45 }, 4n, 'The result of (2n * {toString: function() {return 2n;}}) is 4n');
     46 
     47 reportCompare(0, 0);