summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/Number.isNaN.js
blob: bbd3a5c9c53786dd3880efb5e70454585c9f31af (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
load("test-common.js");

try {
    assert(Number.isNaN !== isNaN);
    assert(Number.isNaN.length === 1);

    assert(Number.isNaN(0) === false);
    assert(Number.isNaN(42) === false);
    assert(Number.isNaN("") === false);
    assert(Number.isNaN("0") === false);
    assert(Number.isNaN("42") === false);
    assert(Number.isNaN(true) === false);
    assert(Number.isNaN(false) === false);
    assert(Number.isNaN(null) === false);
    assert(Number.isNaN([]) === false);
    assert(Number.isNaN(Infinity) === false);
    assert(Number.isNaN(-Infinity) === false);
    assert(Number.isNaN() === false);
    assert(Number.isNaN(undefined) === false);
    assert(Number.isNaN("foo") === false);
    assert(Number.isNaN({}) === false);
    assert(Number.isNaN([1, 2, 3]) === false);

    assert(Number.isNaN(NaN) === true);
    assert(Number.isNaN(Number.NaN) === true);
    assert(Number.isNaN(0 / 0) === true);

    console.log("PASS");
} catch (e) {
    console.log("FAIL: " + e.message);
}