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