1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/basic/hypot-exact.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +// Properties of Math.hypot that are guaranteed by the spec. 1.5 + 1.6 +// If no arguments are passed, the result is +0. 1.7 +assertEq(Math.hypot(), +0); 1.8 + 1.9 +// If any argument is +∞, the result is +∞. 1.10 +// If any argument is −∞, the result is +∞. 1.11 +for (var inf of [Infinity, -Infinity]) { 1.12 + assertEq(Math.hypot(inf, 0), Infinity); 1.13 + assertEq(Math.hypot(0, inf), Infinity); 1.14 + assertEq(Math.hypot(inf, inf), Infinity); 1.15 + assertEq(Math.hypot(inf, -inf), Infinity); 1.16 + 1.17 + assertEq(Math.hypot(inf, -0), Infinity); 1.18 + assertEq(Math.hypot(-0, inf), Infinity); 1.19 + assertEq(Math.hypot(inf, Math.MIN_VALUE), Infinity); 1.20 + assertEq(Math.hypot(Math.MIN_VALUE, inf), Infinity); 1.21 + assertEq(Math.hypot(inf, 1), Infinity); 1.22 + assertEq(Math.hypot(1, inf), Infinity); 1.23 + 1.24 + assertEq(Math.hypot(inf, 0, 0), Infinity); 1.25 + assertEq(Math.hypot(0, inf, 0), Infinity); 1.26 + assertEq(Math.hypot(0, 0, inf), Infinity); 1.27 + 1.28 + assertEq(Math.hypot(inf, NaN), Infinity); 1.29 + assertEq(Math.hypot(NaN, inf), Infinity); 1.30 + 1.31 + assertEq(Math.hypot(inf, NaN, NaN), Infinity); 1.32 + assertEq(Math.hypot(NaN, inf, NaN), Infinity); 1.33 + assertEq(Math.hypot(NaN, NaN, inf), Infinity); 1.34 +} 1.35 + 1.36 +// If no argument is +∞ or −∞, and any argument is NaN, the result is NaN. 1.37 +assertEq(Math.hypot(NaN), NaN); 1.38 + 1.39 +assertEq(Math.hypot(NaN, 0), NaN); 1.40 +assertEq(Math.hypot(0, NaN), NaN); 1.41 + 1.42 +assertEq(Math.hypot(NaN, NaN), NaN); 1.43 + 1.44 +assertEq(Math.hypot(NaN, 0, 0), NaN); 1.45 +assertEq(Math.hypot(0, NaN, 0), NaN); 1.46 +assertEq(Math.hypot(0, 0, NaN), NaN); 1.47 + 1.48 +assertEq(Math.hypot(Number.MAX_VALUE, Number.MIN_VALUE, NaN), NaN); 1.49 + 1.50 +// If all arguments are either +0 or -0, the result is +0. 1.51 +assertEq(Math.hypot(-0, -0), +0); 1.52 +assertEq(Math.hypot(+0, -0), +0); 1.53 + 1.54 +assertEq(Math.hypot(-0, -0, -0), +0); 1.55 +assertEq(Math.hypot(+0, -0, -0), +0); 1.56 +assertEq(Math.hypot(-0, +0, -0), +0); 1.57 +assertEq(Math.hypot(+0, +0, -0), +0); 1.58 + 1.59 +// The length property of the hypot function is 2. 1.60 +assertEq(Math.hypot.length, 2);