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

try {
    assert(Array.of.length === 0);

    assert(typeof Array.of() === "object");

    var a;

    a = Array.of(5);
    assert(a.length === 1);
    assert(a[0] === 5);

    a = Array.of("5");
    assert(a.length === 1);
    assert(a[0] === "5");

    a = Array.of(Infinity);
    assert(a.length === 1);
    assert(a[0] === Infinity);

    a = Array.of(1, 2, 3);
    assert(a.length === 3);
    assert(a[0] === 1);
    assert(a[1] === 2);
    assert(a[2] === 3);

    a = Array.of([1, 2, 3]);
    assert(a.length === 1);
    assert(a[0][0] === 1);
    assert(a[0][1] === 2);
    assert(a[0][2] === 3);

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