tor-browser

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

testShiftRightLogical.js (1367B)


      1 /* Test the proper operation of the logical right shift operator. This is
      2 * especially important on ARM as an explicit mask is required at the native
      3 * instruction level. */
      4 
      5 function testShiftRightLogical()
      6 {
      7    var r = [];
      8    var i = 0;
      9    var j = 0;
     10 
     11    var shifts = [0,1,7,8,15,16,23,24,31];
     12 
     13    /* Samples from the simple shift range. */
     14    for (i = 0; i < shifts.length; i++)
     15        r[j++] = -2147483648 >>> shifts[i];
     16 
     17    /* Samples outside the normal shift range. */
     18    for (i = 0; i < shifts.length; i++)
     19        r[j++] = -2147483648 >>> (shifts[i] + 32);
     20 
     21    /* Samples far outside the normal shift range. */
     22    for (i = 0; i < shifts.length; i++)
     23        r[j++] = -2147483648 >>> (shifts[i] + 224);
     24    for (i = 0; i < shifts.length; i++)
     25        r[j++] = -2147483648 >>> (shifts[i] + 256);
     26 
     27    return r.join(",");
     28 }
     29 /* Note: Arguments to the ">>>" operator are converted to unsigned 32-bit
     30 * integers during evaluation. As a result, -2147483648 >>> 0 evaluates to the
     31 * unsigned interpretation of the same value, which is 2147483648. */
     32 assertEq(testShiftRightLogical(),
     33  "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+
     34  "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+
     35  "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+
     36  "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1");