tor-browser

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

bigint-and-bigint.js (4586B)


      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: Strict equality comparison of BigInt values
      5 esid: sec-strict-equality-comparison
      6 info: |
      7  1. If Type(x) is different from Type(y), return false.
      8  2. If Type(x) is Number or BigInt, then
      9    a. Return ! Type(x)::equal(x, y).
     10 
     11  sec-numeric-types-bigint-equal
     12  BigInt::equal (x, y)
     13 
     14    The abstract operation BigInt::equal with two arguments x and y of BigInt type returns true if x and y have the same mathematical integer value and false otherwise.
     15 
     16 features: [BigInt]
     17 ---*/
     18 assert.sameValue(0n === 0n, true, 'The result of (0n === 0n) is true');
     19 assert.sameValue(1n === 1n, true, 'The result of (1n === 1n) is true');
     20 assert.sameValue(-1n === -1n, true, 'The result of (-1n === -1n) is true');
     21 assert.sameValue(0n === -0n, true, 'The result of (0n === -0n) is true');
     22 assert.sameValue(-0n === 0n, true, 'The result of (-0n === 0n) is true');
     23 assert.sameValue(0n === 1n, false, 'The result of (0n === 1n) is false');
     24 assert.sameValue(1n === 0n, false, 'The result of (1n === 0n) is false');
     25 assert.sameValue(0n === -1n, false, 'The result of (0n === -1n) is false');
     26 assert.sameValue(-1n === 0n, false, 'The result of (-1n === 0n) is false');
     27 assert.sameValue(1n === -1n, false, 'The result of (1n === -1n) is false');
     28 assert.sameValue(-1n === 1n, false, 'The result of (-1n === 1n) is false');
     29 
     30 assert.sameValue(
     31  0x1fffffffffffff01n === 0x1fffffffffffff01n,
     32  true,
     33  'The result of (0x1fffffffffffff01n === 0x1fffffffffffff01n) is true'
     34 );
     35 
     36 assert.sameValue(
     37  0x1fffffffffffff01n === 0x1fffffffffffff02n,
     38  false,
     39  'The result of (0x1fffffffffffff01n === 0x1fffffffffffff02n) is false'
     40 );
     41 
     42 assert.sameValue(
     43  0x1fffffffffffff02n === 0x1fffffffffffff01n,
     44  false,
     45  'The result of (0x1fffffffffffff02n === 0x1fffffffffffff01n) is false'
     46 );
     47 
     48 assert.sameValue(
     49  -0x1fffffffffffff01n === -0x1fffffffffffff01n,
     50  true,
     51  'The result of (-0x1fffffffffffff01n === -0x1fffffffffffff01n) is true'
     52 );
     53 
     54 assert.sameValue(
     55  -0x1fffffffffffff01n === -0x1fffffffffffff02n,
     56  false,
     57  'The result of (-0x1fffffffffffff01n === -0x1fffffffffffff02n) is false'
     58 );
     59 
     60 assert.sameValue(
     61  -0x1fffffffffffff02n === -0x1fffffffffffff01n,
     62  false,
     63  'The result of (-0x1fffffffffffff02n === -0x1fffffffffffff01n) is false'
     64 );
     65 
     66 assert.sameValue(
     67  0x10000000000000000n === 0n,
     68  false,
     69  'The result of (0x10000000000000000n === 0n) is false'
     70 );
     71 
     72 assert.sameValue(
     73  0n === 0x10000000000000000n,
     74  false,
     75  'The result of (0n === 0x10000000000000000n) is false'
     76 );
     77 
     78 assert.sameValue(
     79  0x10000000000000000n === 1n,
     80  false,
     81  'The result of (0x10000000000000000n === 1n) is false'
     82 );
     83 
     84 assert.sameValue(
     85  1n === 0x10000000000000000n,
     86  false,
     87  'The result of (1n === 0x10000000000000000n) is false'
     88 );
     89 
     90 assert.sameValue(
     91  0x10000000000000000n === -1n,
     92  false,
     93  'The result of (0x10000000000000000n === -1n) is false'
     94 );
     95 
     96 assert.sameValue(
     97  -1n === 0x10000000000000000n,
     98  false,
     99  'The result of (-1n === 0x10000000000000000n) is false'
    100 );
    101 
    102 assert.sameValue(
    103  0x10000000000000001n === 0n,
    104  false,
    105  'The result of (0x10000000000000001n === 0n) is false'
    106 );
    107 
    108 assert.sameValue(
    109  0n === 0x10000000000000001n,
    110  false,
    111  'The result of (0n === 0x10000000000000001n) is false'
    112 );
    113 
    114 assert.sameValue(
    115  -0x10000000000000000n === 0n,
    116  false,
    117  'The result of (-0x10000000000000000n === 0n) is false'
    118 );
    119 
    120 assert.sameValue(
    121  0n === -0x10000000000000000n,
    122  false,
    123  'The result of (0n === -0x10000000000000000n) is false'
    124 );
    125 
    126 assert.sameValue(
    127  -0x10000000000000000n === 1n,
    128  false,
    129  'The result of (-0x10000000000000000n === 1n) is false'
    130 );
    131 
    132 assert.sameValue(
    133  1n === -0x10000000000000000n,
    134  false,
    135  'The result of (1n === -0x10000000000000000n) is false'
    136 );
    137 
    138 assert.sameValue(
    139  -0x10000000000000000n === -1n,
    140  false,
    141  'The result of (-0x10000000000000000n === -1n) is false'
    142 );
    143 
    144 assert.sameValue(
    145  -1n === -0x10000000000000000n,
    146  false,
    147  'The result of (-1n === -0x10000000000000000n) is false'
    148 );
    149 
    150 assert.sameValue(
    151  -0x10000000000000001n === 0n,
    152  false,
    153  'The result of (-0x10000000000000001n === 0n) is false'
    154 );
    155 
    156 assert.sameValue(
    157  0n === -0x10000000000000001n,
    158  false,
    159  'The result of (0n === -0x10000000000000001n) is false'
    160 );
    161 
    162 assert.sameValue(
    163  0x10000000000000000n === 0x100000000n,
    164  false,
    165  'The result of (0x10000000000000000n === 0x100000000n) is false'
    166 );
    167 
    168 assert.sameValue(
    169  0x100000000n === 0x10000000000000000n,
    170  false,
    171  'The result of (0x100000000n === 0x10000000000000000n) is false'
    172 );
    173 
    174 reportCompare(0, 0);