summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Math/sign.js
blob: 5552dfc3d4aabf28ac84db9109de8369a576a773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// If x is NaN, the result is NaN.
assertEq(Math.sign(NaN), NaN);

// If x is −0, the result is −0.
assertEq(Math.sign(-0), -0);

// If x is +0, the result is +0.
assertEq(Math.sign(+0), +0);

// If x is negative and not −0, the result is −1.
assertEq(Math.sign(-Number.MIN_VALUE), -1);
assertEq(Math.sign(-Number.MAX_VALUE), -1);
assertEq(Math.sign(-Infinity), -1);

for (var i = -1; i > -20; i--)
    assertEq(Math.sign(i), -1);

assertEq(Math.sign(-1e-300), -1);
assertEq(Math.sign(-0x80000000), -1);

// If x is positive and not +0, the result is +1.
assertEq(Math.sign(Number.MIN_VALUE), +1);
assertEq(Math.sign(Number.MAX_VALUE), +1);
assertEq(Math.sign(Infinity), +1);

for (var i = 1; i < 20; i++)
    assertEq(Math.sign(i), +1);

assertEq(Math.sign(+1e-300), +1);
assertEq(Math.sign(0x80000000), +1);
assertEq(Math.sign(0xffffffff), +1);


reportCompare(0, 0, "ok");