summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/jaeger/testSetElem-Easy.js
blob: ed8fc7c9a9bb3de3f4e6b841e036a5ae4c29d902 (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
// vim: set ts=8 sts=4 et sw=4 tw=99:

function testBadSetElems(obj, key) {
    obj[key] = 5;
    obj[-1] = 5;
    var L = obj;
    L[L] = L;
    obj = [];
    obj.K = 5;
    obj[2] = 5;
    var T = "a";
    obj[T] = 12;
    obj = [];
    obj[Object] = key;
}

function testDenseSets(L) {
    var obj = [,,,,,,,,,,];
    obj[2] = 2;
    assertEq(obj[2], 2);
    var T = L;
    assertEq(obj[T], 2);
    assertEq(obj.length, 10);
    obj[10] = T;
    assertEq(obj[10], T);
    assertEq(obj.length, 11);
    var K = T + 9;
    obj[K] = K;
    assertEq(obj[K], K);
    assertEq(obj.length, 12);
    obj[K + 1] = obj;
    assertEq(obj[K + 1], obj);
    assertEq(obj.length, 13);
}

for (var i = 0; i < 10; i++) {
    testBadSetElems([], -1);
    testDenseSets(2);
}