Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / jit-test / tests / basic / testShiftRightLogical.js
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 load(libdir + 'range.js');
6
7 function testShiftRightLogical()
8 {
9     var r = [];
10     var i = 0;
11     var j = 0;
12
13     var shifts = [0,1,7,8,15,16,23,24,31];
14
15     /* Samples from the simple shift range. */
16     for (i = 0; i < shifts.length; i++)
17         r[j++] = -2147483648 >>> shifts[i];
18
19     /* Samples outside the normal shift range. */
20     for (i = 0; i < shifts.length; i++)
21         r[j++] = -2147483648 >>> (shifts[i] + 32);
22
23     /* Samples far outside the normal shift range. */
24     for (i = 0; i < shifts.length; i++)
25         r[j++] = -2147483648 >>> (shifts[i] + 224);
26     for (i = 0; i < shifts.length; i++)
27         r[j++] = -2147483648 >>> (shifts[i] + 256);
28
29     return r.join(",");
30 }
31 /* Note: Arguments to the ">>>" operator are converted to unsigned 32-bit
32  * integers during evaluation. As a result, -2147483648 >>> 0 evaluates to the
33  * unsigned interpretation of the same value, which is 2147483648. */
34 assertEq(testShiftRightLogical(),
35          "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+
36          "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+
37          "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+
38          "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1");