summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/Array.isArray.js
blob: 714f6e08ea0f19aa4ddf5553c4fb6bd242995512 (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
load("test-common.js");

try {
    assert(Array.isArray.length === 1);

    assert(Array.isArray() === false);
    assert(Array.isArray("1") === false);
    assert(Array.isArray("foo") === false);
    assert(Array.isArray(1) === false);
    assert(Array.isArray(1, 2, 3) === false);
    assert(Array.isArray(undefined) === false);
    assert(Array.isArray(null) === false);
    assert(Array.isArray(Infinity) === false);
    assert(Array.isArray({}) === false);

    assert(Array.isArray([]) === true);
    assert(Array.isArray([1]) === true);
    assert(Array.isArray([1, 2, 3]) === true);
    assert(Array.isArray(new Array()) === true);
    assert(Array.isArray(new Array(10)) === true);
    assert(Array.isArray(new Array("a", "b", "c")) === true);
    // FIXME: Array.prototype is supposed to be an array!
    // assert(Array.isArray(Array.prototype) === true);

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