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
122
123
124
125
126
127
128
129
130
131
132
133
134
|
var IsCallable = getSelfHostedValue("IsCallable");
setJitCompilerOption("ion.warmup.trigger", 50);
function testSinglePrimitive() {
var f1 = function() { assertEq(IsCallable(undefined), false); };
do { f1(); } while (!inIon());
var f2 = function() { assertEq(IsCallable(null), false); };
do { f2(); } while (!inIon());
var f3 = function() { assertEq(IsCallable(true), false); };
do { f3(); } while (!inIon());
var f4 = function() { assertEq(IsCallable(1), false); };
do { f4(); } while (!inIon());
var f5 = function() { assertEq(IsCallable(1.2), false); };
do { f5(); } while (!inIon());
var f6 = function() { assertEq(IsCallable("foo"), false); };
do { f6(); } while (!inIon());
var f7 = function() { assertEq(IsCallable(Symbol.iterator), false); };
do { f7(); } while (!inIon());
}
testSinglePrimitive();
function testMixedPrimitive() {
var list = [
undefined,
null,
true,
1,
1.2,
"foo",
Symbol.iterator,
];
var f1 = function() {
for (let x of list) {
assertEq(IsCallable(x), false);
}
};
do { f1(); } while (!inIon());
}
testMixedPrimitive();
function testSingleObject() {
var obj = [];
var arr = [];
var f1 = function() { assertEq(IsCallable(obj), false); };
do { f1(); } while (!inIon());
var f2 = function() { assertEq(IsCallable(arr), false); };
do { f2(); } while (!inIon());
}
testSingleObject();
function testMixedPrimitiveAndObject() {
var list = [
undefined,
null,
true,
1,
1.2,
"foo",
Symbol.iterator,
{},
[],
];
var f1 = function() {
for (let x of list) {
assertEq(IsCallable(x), false);
}
};
do { f1(); } while (!inIon());
}
testMixedPrimitiveAndObject();
function testFunction() {
var f1 = function() { assertEq(IsCallable(Function), true); };
do { f1(); } while (!inIon());
var f2 = function() { assertEq(IsCallable(parseInt), true); };
do { f2(); } while (!inIon());
}
testFunction();
function testProxy() {
var p1 = new Proxy({}, {});
var f1 = function() { assertEq(IsCallable(p1), false); };
do { f1(); } while (!inIon());
var p2 = new Proxy(function() {}, {});
var f2 = function() { assertEq(IsCallable(p2), true); };
do { f2(); } while (!inIon());
}
testProxy();
function testMixed() {
var p1 = new Proxy({}, {});
var p2 = new Proxy(function() {}, {});
var list = [
[undefined, false],
[null, false],
[true, false],
[1, false],
[1.2, false],
["foo", false],
[Symbol.iterator, false],
[{}, false],
[[], false],
[Function, true],
[parseInt, true],
[p1, false],
[p2, true],
];
var f1 = function() {
for (let [x, expected] of list) {
assertEq(IsCallable(x), expected);
}
};
do { f1(); } while (!inIon());
}
testMixed();
|