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
|
// |jit-test| --ion-warmup-threshold=50
setJitCompilerOption("offthread-compilation.enable", 0);
gcPreserveCode();
function test1() {
var caughtInvalidArguments = false;
var a = -1
try {
var buf = new Uint8ClampedArray(a);
throw new Error("didn't throw");
} catch (e) {
assertEq(e instanceof RangeError, true,
"expected RangeError, instead threw: " + e);
caughtInvalidArguments = true;
}
assertEq(caughtInvalidArguments, true);
}
test1();
function test2() {
var caughtInvalidArguments = false;
var i = 0;
while (true) {
i = (i + 1) | 0;
var a = inIon() ? -1 : 300;
try {
var buf = new Uint8ClampedArray(a);
assertEq(buf.length, 300);
} catch (e) {
assertEq(a, -1);
assertEq(e instanceof RangeError, true,
"expected RangeError, instead threw: " + e);
caughtInvalidArguments = true;
break;
}
}
assertEq(caughtInvalidArguments, true);
}
test2();
function test3() {
var caughtInvalidArguments = false;
var i = 0;
while (true) {
i = (i + 1) | 0;
var a = inIon() ? -1 : 0;
try {
var buf = new Uint8ClampedArray(a);
assertEq(buf.length, 0);
} catch (e) {
assertEq(a, -1);
assertEq(e instanceof RangeError, true,
"expected RangeError, instead threw: " + e);
caughtInvalidArguments = true;
break;
}
}
assertEq(caughtInvalidArguments, true);
}
test3();
|