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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
load("test-common.js");
try {
assert(+false === 0);
assert(-false === 0);
assert(+true === 1);
assert(-true === -1);
assert(+null === 0);
assert(-null === 0);
assert(+[] === 0);
assert(-[] === 0);
assert(+[,] === 0);
assert(-[,] === 0);
assert(+[null] === 0);
assert(-[null] === 0);
assert(+[undefined] === 0);
assert(-[undefined] === 0);
assert(+[[[[[]]]]] === 0);
assert(-[[[[[]]]]] === 0);
assert(+[[[[[42]]]]] === 42);
assert(-[[[[[42]]]]] === -42);
assert(+"" === 0);
assert(-"" === 0);
assert(+"42" === 42);
assert(-"42" === -42);
assert(+42 === 42);
assert(-42 === -42);
assert(+1.23 === 1.23);
assert(-1.23 === -1.23);
assert(+"1.23" === 1.23)
assert(-"1.23" === -1.23)
assert(+"Infinity" === Infinity);
assert(+"+Infinity" === Infinity);
assert(+"-Infinity" === -Infinity);
assert(-"Infinity" === -Infinity);
assert(-"+Infinity" === -Infinity);
assert(-"-Infinity" === Infinity);
assert(+" \r \t \n " === 0);
assert(+" \n \t Infinity \r " === Infinity);
assert(+"\r \n1.23 \t\t\t \n" === 1.23);
assert(isNaN(+undefined));
assert(isNaN(-undefined));
assert(isNaN(+{}));
assert(isNaN(-{}));
assert(isNaN(+{ a: 1 }));
assert(isNaN(-{ a: 1 }));
assert(isNaN(+[, , ,]));
assert(isNaN(-[, , ,]));
assert(isNaN(+[undefined, undefined]));
assert(isNaN(-[undefined, undefined]));
assert(isNaN(+[1, 2, 3]));
assert(isNaN(-[1, 2, 3]));
assert(isNaN(+[[[["foo"]]]]));
assert(isNaN(-[[[["foo"]]]]));
assert(isNaN(+"foo"));
assert(isNaN(-"foo"));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
|