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 | // Properties of Math.hypot that are guaranteed by the spec. |
michael@0 | 2 | |
michael@0 | 3 | // If no arguments are passed, the result is +0. |
michael@0 | 4 | assertEq(Math.hypot(), +0); |
michael@0 | 5 | |
michael@0 | 6 | // If any argument is +∞, the result is +∞. |
michael@0 | 7 | // If any argument is −∞, the result is +∞. |
michael@0 | 8 | for (var inf of [Infinity, -Infinity]) { |
michael@0 | 9 | assertEq(Math.hypot(inf, 0), Infinity); |
michael@0 | 10 | assertEq(Math.hypot(0, inf), Infinity); |
michael@0 | 11 | assertEq(Math.hypot(inf, inf), Infinity); |
michael@0 | 12 | assertEq(Math.hypot(inf, -inf), Infinity); |
michael@0 | 13 | |
michael@0 | 14 | assertEq(Math.hypot(inf, -0), Infinity); |
michael@0 | 15 | assertEq(Math.hypot(-0, inf), Infinity); |
michael@0 | 16 | assertEq(Math.hypot(inf, Math.MIN_VALUE), Infinity); |
michael@0 | 17 | assertEq(Math.hypot(Math.MIN_VALUE, inf), Infinity); |
michael@0 | 18 | assertEq(Math.hypot(inf, 1), Infinity); |
michael@0 | 19 | assertEq(Math.hypot(1, inf), Infinity); |
michael@0 | 20 | |
michael@0 | 21 | assertEq(Math.hypot(inf, 0, 0), Infinity); |
michael@0 | 22 | assertEq(Math.hypot(0, inf, 0), Infinity); |
michael@0 | 23 | assertEq(Math.hypot(0, 0, inf), Infinity); |
michael@0 | 24 | |
michael@0 | 25 | assertEq(Math.hypot(inf, NaN), Infinity); |
michael@0 | 26 | assertEq(Math.hypot(NaN, inf), Infinity); |
michael@0 | 27 | |
michael@0 | 28 | assertEq(Math.hypot(inf, NaN, NaN), Infinity); |
michael@0 | 29 | assertEq(Math.hypot(NaN, inf, NaN), Infinity); |
michael@0 | 30 | assertEq(Math.hypot(NaN, NaN, inf), Infinity); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | // If no argument is +∞ or −∞, and any argument is NaN, the result is NaN. |
michael@0 | 34 | assertEq(Math.hypot(NaN), NaN); |
michael@0 | 35 | |
michael@0 | 36 | assertEq(Math.hypot(NaN, 0), NaN); |
michael@0 | 37 | assertEq(Math.hypot(0, NaN), NaN); |
michael@0 | 38 | |
michael@0 | 39 | assertEq(Math.hypot(NaN, NaN), NaN); |
michael@0 | 40 | |
michael@0 | 41 | assertEq(Math.hypot(NaN, 0, 0), NaN); |
michael@0 | 42 | assertEq(Math.hypot(0, NaN, 0), NaN); |
michael@0 | 43 | assertEq(Math.hypot(0, 0, NaN), NaN); |
michael@0 | 44 | |
michael@0 | 45 | assertEq(Math.hypot(Number.MAX_VALUE, Number.MIN_VALUE, NaN), NaN); |
michael@0 | 46 | |
michael@0 | 47 | // If all arguments are either +0 or -0, the result is +0. |
michael@0 | 48 | assertEq(Math.hypot(-0, -0), +0); |
michael@0 | 49 | assertEq(Math.hypot(+0, -0), +0); |
michael@0 | 50 | |
michael@0 | 51 | assertEq(Math.hypot(-0, -0, -0), +0); |
michael@0 | 52 | assertEq(Math.hypot(+0, -0, -0), +0); |
michael@0 | 53 | assertEq(Math.hypot(-0, +0, -0), +0); |
michael@0 | 54 | assertEq(Math.hypot(+0, +0, -0), +0); |
michael@0 | 55 | |
michael@0 | 56 | // The length property of the hypot function is 2. |
michael@0 | 57 | assertEq(Math.hypot.length, 2); |