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

try {
    assert(Boolean.length === 1);
    assert(Boolean.name === "Boolean");
    assert(Boolean.prototype.length === undefined);

    assert(typeof new Boolean() === "object");
    assert(new Boolean().valueOf() === false);

    var foo = new Boolean(true);
    var bar = new Boolean(true);

    assert(foo !== bar);
    assert(foo.valueOf() === bar.valueOf());

    assert(new Boolean(true).toString() === "true");
    assert(new Boolean(false).toString() === "false");

    assert(typeof Boolean() === "boolean");
    assert(typeof Boolean(true) === "boolean");

    assert(Boolean() === false);
    assert(Boolean(false) === false);
    assert(Boolean(null) === false);
    assert(Boolean(undefined) === false);
    assert(Boolean(NaN) === false);
    assert(Boolean("") === false);
    assert(Boolean(0.0) === false);
    assert(Boolean(-0.0) === false);
    assert(Boolean(true) === true);
    assert(Boolean("0") === true);
    assert(Boolean({}) === true);
    assert(Boolean([]) === true);
    assert(Boolean(1)) === true;

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