summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/known-class.js
blob: 61e6f2afe20d2f49f87c50ce36b623a571e7835e (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var IsRegExpObject = getSelfHostedValue("IsRegExpObject");
var IsCallable = getSelfHostedValue("IsCallable");
var NewArrayIterator = getSelfHostedValue("NewArrayIterator");
var GuardToArrayIterator = getSelfHostedValue("GuardToArrayIterator");

function array() {
    var a = [0];
    assertEq(Array.isArray(a), true);
    assertEq(typeof a, "object");
    assertEq(IsRegExpObject(a), false);
    assertEq(IsCallable(a), false);
}

function array2(x) {
    var a;
    if (x) {
        a = [0];
    } else {
        a = [1];
    }
    assertEq(Array.isArray(a), true);
    assertEq(typeof a, "object");
    assertEq(IsRegExpObject(a), false);
    assertEq(IsCallable(a), false);
}

function object() {
    var o = {a: 1};
    assertEq(Array.isArray(o), false);
    assertEq(typeof o, "object");
    assertEq(IsRegExpObject(o), false);
    assertEq(IsCallable(o), false);
}

function object2(x) {
    var o;
    if (x) {
        o = {a: 1};
    } else {
        o = {b: 1};
    }
    assertEq(Array.isArray(o), false);
    assertEq(typeof o, "object");
    assertEq(IsRegExpObject(o), false);
    assertEq(IsCallable(o), false);
}

function mixed(x) {
    var o;
    if (x) {
        o = [1];
    } else {
        o = {a: 1};
    }
    assertEq(Array.isArray(o), x);
    assertEq(typeof o, "object");
    assertEq(IsRegExpObject(o), false);
    assertEq(IsCallable(o), false);
}

function lambda() {
    function f() {}
    assertEq(Array.isArray(f), false);
    assertEq(typeof f, "function");
    assertEq(IsRegExpObject(f), false);
    assertEq(IsCallable(f), true);
}

function arrow() {
    var f = () => {};
    assertEq(Array.isArray(f), false);
    assertEq(typeof f, "function");
    assertEq(IsRegExpObject(f), false);
    assertEq(IsCallable(f), true);
}

function regexp() {
    var r = /a/;
    assertEq(Array.isArray(r), false);
    assertEq(typeof r, "object");
    assertEq(IsRegExpObject(r), true);
    assertEq(IsCallable(r), false);
}

function regexp2(x) {
    var a;
    if (x) {
        a = /a/;
    } else {
        a = /b/;
    }
    assertEq(Array.isArray(a), false);
    assertEq(typeof a, "object");
    assertEq(IsRegExpObject(a), true);
    assertEq(IsCallable(a), false);
}

function iterator() {
    var i = NewArrayIterator();
    assertEq(Array.isArray(i), false);
    assertEq(typeof i, "object");
    assertEq(IsRegExpObject(i), false);
    assertEq(IsCallable(i), false);
    assertEq(GuardToArrayIterator(i), i);
}

var b = true;
for (var i = 0; i < 1e4; i++) {
    array();
    array2(b);
    object();
    object2(b);
    mixed(b);
    lambda();
    arrow();
    regexp()
    regexp2(b);
    iterator();

    b = !b;
}