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 Math.floor() for IonMonkey. |
michael@0 | 2 | // Requires --ion-eager to enter at the top of each loop. |
michael@0 | 3 | |
michael@0 | 4 | var floorDTests = [ |
michael@0 | 5 | [-0, -0], |
michael@0 | 6 | [0.49999999999999997, 0], |
michael@0 | 7 | [0.5, 0], |
michael@0 | 8 | [1.0, 1], |
michael@0 | 9 | [1.5, 1], |
michael@0 | 10 | [792.8, 792], |
michael@0 | 11 | [-0.1, -1], |
michael@0 | 12 | [-1.0001, -2], |
michael@0 | 13 | [-3.14, -4], |
michael@0 | 14 | [2137483649.5, 2137483649], |
michael@0 | 15 | [2137483648.5, 2137483648], |
michael@0 | 16 | [2137483647.1, 2137483647], |
michael@0 | 17 | [900000000000, 900000000000], |
michael@0 | 18 | [-0, -0], |
michael@0 | 19 | [-Infinity, -Infinity], |
michael@0 | 20 | [Infinity, Infinity], |
michael@0 | 21 | [NaN, NaN], |
michael@0 | 22 | [-2147483648.8, -2147483649], |
michael@0 | 23 | [-2147483649.8, -2147483650] |
michael@0 | 24 | ]; |
michael@0 | 25 | |
michael@0 | 26 | var floorITests = [ |
michael@0 | 27 | [0, 0], |
michael@0 | 28 | [4, 4], |
michael@0 | 29 | [-1, -1], |
michael@0 | 30 | [-7, -7], |
michael@0 | 31 | [2147483648, 2147483648], |
michael@0 | 32 | [-2147483649, -2147483649] |
michael@0 | 33 | ]; |
michael@0 | 34 | |
michael@0 | 35 | // Typed functions to be compiled by Ion. |
michael@0 | 36 | function floorD(x) { return Math.floor(x); } |
michael@0 | 37 | function floorI(x) { return Math.floor(x); } |
michael@0 | 38 | |
michael@0 | 39 | function test() { |
michael@0 | 40 | // Always run this function in the interpreter. |
michael@0 | 41 | try {} catch (e) {} |
michael@0 | 42 | |
michael@0 | 43 | for (var i = 0; i < floorDTests.length; i++) |
michael@0 | 44 | assertEq(floorD(floorDTests[i][0]), floorDTests[i][1]); |
michael@0 | 45 | for (var i = 0; i < floorITests.length; i++) |
michael@0 | 46 | assertEq(floorI(floorITests[i][0]), floorITests[i][1]); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | for (var i = 0; i < 40; i++) |
michael@0 | 50 | test(); |