summaryrefslogtreecommitdiff
path: root/js/src/jit-test/tests/ion/bug809021.js
blob: c4c3d436be743ef4d722308d8067b6232caea158 (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
// nactuals > nformals
function testOverflow() {
    var called = false;
    function f(a) {
        assertEq(a, 173);
        assertEq(arguments.length, 2);
        assertEq(arguments[0], a);
        assertEq(arguments[1], a);
        called = true;
    }

    for (var i=0; i<10; i++)
        [173, 173, 173].sort(f);
    assertEq(called, true);
}
testOverflow();

// nactuals == nformals
function testEqual() {
    var called = false;
    function f(a, b) {
        assertEq(a, 173);
        assertEq(arguments.length, 2);
        assertEq(arguments[0], a);
        assertEq(arguments[1], b);
        called = true;
    }

    for (var i=0; i<10; i++)
        [173, 173, 173].sort(f);
    assertEq(called, true);
}
testEqual();

// nactuals < nformals
function testUnderflow() {
    var called = false;
    function f(a, b, c) {
        assertEq(a, 173);
        assertEq(c, undefined);
        assertEq(arguments.length, 2);
        assertEq(arguments[0], a);
        assertEq(arguments[1], b);
        called = true;
    }

    for (var i=0; i<10; i++)
        [173, 173, 173].sort(f);
    assertEq(called, true);
}
testUnderflow();

function testUnderflowMany() {
    var called = 0;
    function f(a, b, c, d, e, f, g, h) {
        assertEq(a, 173);
        assertEq(arguments.length, 3);
        assertEq(arguments[0], a);
        assertEq(arguments[1] < 3, true);
        assertEq(c.length, 3);
        assertEq(d, undefined);
        assertEq(e, undefined);
        assertEq(f, undefined);
        assertEq(g, undefined);
        assertEq(h, undefined);
        called += 1;
    }

    for (var i=0; i<10; i++)
        [173, 173, 173].map(f);
    assertEq(called, 30);
}
testUnderflowMany();