summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/bug1292858.js
blob: 788eb96523966141a1c559c4d5ee844f10458dc6 (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
var caughtInvalidArguments = false;
var a = -1
try {
    var buf = new Uint8ClampedArray(a);
    throw new Error("didn't throw");
} catch (e) {
    assertEq(e instanceof TypeError, true,
             "expected TypeError, instead threw: " + e);
    caughtInvalidArguments = true;
}
assertEq(caughtInvalidArguments, true);

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 TypeError, true,
                "expected TypeError, instead threw: " + e);
        caughtInvalidArguments = true;
        break;
    }
}
assertEq(caughtInvalidArguments, true);

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 TypeError, true,
                "expected TypeError, instead threw: " + e);
        caughtInvalidArguments = true;
        break;
    }
}
assertEq(caughtInvalidArguments, true);