1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/basic/testShiftRightLogical.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +/* Test the proper operation of the logical right shift operator. This is 1.5 + * especially important on ARM as an explicit mask is required at the native 1.6 + * instruction level. */ 1.7 + 1.8 +load(libdir + 'range.js'); 1.9 + 1.10 +function testShiftRightLogical() 1.11 +{ 1.12 + var r = []; 1.13 + var i = 0; 1.14 + var j = 0; 1.15 + 1.16 + var shifts = [0,1,7,8,15,16,23,24,31]; 1.17 + 1.18 + /* Samples from the simple shift range. */ 1.19 + for (i = 0; i < shifts.length; i++) 1.20 + r[j++] = -2147483648 >>> shifts[i]; 1.21 + 1.22 + /* Samples outside the normal shift range. */ 1.23 + for (i = 0; i < shifts.length; i++) 1.24 + r[j++] = -2147483648 >>> (shifts[i] + 32); 1.25 + 1.26 + /* Samples far outside the normal shift range. */ 1.27 + for (i = 0; i < shifts.length; i++) 1.28 + r[j++] = -2147483648 >>> (shifts[i] + 224); 1.29 + for (i = 0; i < shifts.length; i++) 1.30 + r[j++] = -2147483648 >>> (shifts[i] + 256); 1.31 + 1.32 + return r.join(","); 1.33 +} 1.34 +/* Note: Arguments to the ">>>" operator are converted to unsigned 32-bit 1.35 + * integers during evaluation. As a result, -2147483648 >>> 0 evaluates to the 1.36 + * unsigned interpretation of the same value, which is 2147483648. */ 1.37 +assertEq(testShiftRightLogical(), 1.38 + "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+ 1.39 + "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+ 1.40 + "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1,"+ 1.41 + "2147483648,1073741824,16777216,8388608,65536,32768,256,128,1");