js/src/jit-test/tests/ion/mathRound.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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.round() for IonMonkey.
michael@0 2 // Requires --ion-eager to enter at the top of each loop.
michael@0 3
michael@0 4 var roundDTests = [
michael@0 5 [-0, -0],
michael@0 6 [0.49999999999999997, 1],
michael@0 7 [0.5, 1],
michael@0 8 [1.0, 1],
michael@0 9 [1.5, 2],
michael@0 10 [792.8, 793],
michael@0 11 [-0.1, -0],
michael@0 12 [-1.0001, -1],
michael@0 13 [-3.14, -3],
michael@0 14 [2137483649.5, 2137483650],
michael@0 15 [2137483648.5, 2137483649],
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 roundITests = [
michael@0 27 [0, 0],
michael@0 28 [4, 4],
michael@0 29 [2147483648, 2147483648],
michael@0 30 [-2147483649, -2147483649]
michael@0 31 ];
michael@0 32
michael@0 33 // Typed functions to be compiled by Ion.
michael@0 34 function roundD(x) { return Math.round(x); }
michael@0 35 function roundI(x) { return Math.round(x); }
michael@0 36
michael@0 37 function test() {
michael@0 38 // Always run this function in the interpreter.
michael@0 39 try {} catch (e) {}
michael@0 40
michael@0 41 for (var i = 0; i < roundDTests.length; i++)
michael@0 42 assertEq(roundD(roundDTests[i][0]), roundDTests[i][1]);
michael@0 43 for (var i = 0; i < roundITests.length; i++)
michael@0 44 assertEq(roundI(roundITests[i][0]), roundITests[i][1]);
michael@0 45 }
michael@0 46
michael@0 47 for (var i = 0; i < 40; i++)
michael@0 48 test();

mercurial