blob: e60233b8cb6aa2b6db0e0b626acb12689f1a403e (
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
35
36
37
38
39
40
41
42
|
load("test-common.js");
function isPositiveZero(value) {
return value === 0 && 1 / value === Infinity;
}
function isNegativeZero(value) {
return value === 0 && 1 / value === -Infinity;
}
try {
assert(Math.sign.length === 1);
assert(Math.sign(0.0001) === 1);
assert(Math.sign(1) === 1);
assert(Math.sign(42) === 1);
assert(Math.sign(Infinity) === 1);
assert(isPositiveZero(Math.sign(0)));
assert(isPositiveZero(Math.sign(null)));
assert(isPositiveZero(Math.sign('')));
assert(isPositiveZero(Math.sign([])));
assert(Math.sign(-0.0001) === -1);
assert(Math.sign(-1) === -1);
assert(Math.sign(-42) === -1);
assert(Math.sign(-Infinity) === -1);
assert(isNegativeZero(Math.sign(-0)));
assert(isNegativeZero(Math.sign(-null)));
assert(isNegativeZero(Math.sign(-'')));
assert(isNegativeZero(Math.sign(-[])));
assert(isNaN(Math.sign()));
assert(isNaN(Math.sign(undefined)));
assert(isNaN(Math.sign([1, 2, 3])));
assert(isNaN(Math.sign({})));
assert(isNaN(Math.sign(NaN)));
assert(isNaN(Math.sign("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
|