tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mathRound.js (1060B)


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