js/src/jit-test/tests/basic/testShiftRightArithmetic.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Test the proper operation of the arithmetic right shift operator. This is
     2  * especially important on ARM as an explicit mask is required at the native
     3  * instruction level. */
     5 load(libdir + 'range.js');
     7 /* Test different combinations of literals/variables. */
     8 var s = 4;
     9 var t = 100;
    10 assertEq(42 >> s, 2);
    11 assertEq(s >> 1, 2);
    12 assertEq(23 >> 3, 2);
    13 assertEq(t >> s, 6);
    16 function testShiftRightArithmetic()
    17 {
    18     var r = [];
    19     var i = 0;
    20     var j = 0;
    22     var shifts = [0,1,7,8,15,16,23,24,31];
    24     /* Samples from the simple shift range. */
    25     for (i = 0; i < shifts.length; i++)
    26         r[j++] = -2147483648 >> shifts[i];
    28     /* Samples outside the normal shift range. */
    29     for (i = 0; i < shifts.length; i++)
    30         r[j++] = -2147483648 >> (shifts[i] + 32);
    32     /* Samples far outside the normal shift range. */
    33     for (i = 0; i < shifts.length; i++)
    34         r[j++] = -2147483648 >> (shifts[i] + 224);
    35     for (i = 0; i < shifts.length; i++)
    36         r[j++] = -2147483648 >> (shifts[i] + 256);
    38     return r.join(",");
    39 }
    40 assertEq(testShiftRightArithmetic(), 
    41 	 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1,"+
    42 	 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1,"+
    43 	 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1,"+
    44 	 "-2147483648,-1073741824,-16777216,-8388608,-65536,-32768,-256,-128,-1");

mercurial