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