tor-browser

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

bigint-non-primitive.js (1812B)


      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: Unary minus for BigInt object wrappers
      5 esid: sec-unary-minus-operator-runtime-semantics-evaluation
      6 info: |
      7  Runtime Semantics: Evaluation
      8  UnaryExpression : - UnaryExpression
      9 
     10  1. Let expr be the result of evaluating UnaryExpression.
     11  2. Let oldValue be ? ToNumeric(? GetValue(expr)).
     12  3. Let T be Type(oldValue).
     13  4. Return ? T::unaryMinus(oldValue).
     14 
     15 features: [BigInt, Symbol.toPrimitive]
     16 ---*/
     17 assert.sameValue(-Object(1n), -1n, 'The value of -Object(1n) is -1n');
     18 assert.notSameValue(-Object(1n), 1n, 'The value of -Object(1n) is not 1n');
     19 assert.notSameValue(-Object(1n), Object(-1n), 'The value of -Object(1n) is not Object(-1n)');
     20 assert.sameValue(-Object(-1n), 1n, 'The value of -Object(-1n) is 1n');
     21 assert.notSameValue(-Object(-1n), -1n, 'The value of -Object(-1n) is not -1n');
     22 assert.notSameValue(-Object(-1n), Object(1n), 'The value of -Object(-1n) is not Object(1n)');
     23 
     24 assert.sameValue(-{
     25  [Symbol.toPrimitive]: function() {
     26    return 1n;
     27  },
     28 
     29  valueOf: function() {
     30    throw new Test262Error();
     31  },
     32 
     33  toString: function() {
     34    throw new Test262Error();
     35  }
     36 }, -1n, 'The value of -{[Symbol.toPrimitive]: function() {return 1n;}, valueOf: function() {throw new Test262Error();}, toString: function() {throw new Test262Error();}} is -1n');
     37 
     38 assert.sameValue(-{
     39  valueOf: function() {
     40    return 1n;
     41  },
     42 
     43  toString: function() {
     44    throw new Test262Error();
     45  }
     46 }, -1n, 'The value of -{valueOf: function() {return 1n;}, toString: function() {throw new Test262Error();}} is -1n');
     47 
     48 assert.sameValue(-{
     49  toString: function() {
     50    return 1n;
     51  }
     52 }, -1n, 'The value of -{toString: function() {return 1n;}} is -1n');
     53 
     54 reportCompare(0, 0);