PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/jaeger/testSetElem-Easy.js

http://github.com/zpao/v8monkey
JavaScript | 41 lines | 35 code | 5 blank | 1 comment | 1 complexity | b2a43db4164abe6c3af87d16139d5775 MD5 | raw file
 1// vim: set ts=4 sw=4 tw=99 et:
 2
 3function testBadSetElems(obj, key) {
 4    obj[key] = 5;
 5    obj[-1] = 5;
 6    var L = obj;
 7    L[L] = L;
 8    obj = [];
 9    obj.K = 5;
10    obj[2] = 5;
11    var T = "a";
12    obj[T] = 12;
13    obj = [];
14    obj[Object] = key;
15}
16
17function testDenseSets(L) {
18    var obj = [,,,,,,,,,,];
19    obj[2] = 2;
20    assertEq(obj[2], 2);
21    var T = L;
22    assertEq(obj[T], 2);
23    assertEq(obj.length, 10);
24    obj[10] = T;
25    assertEq(obj[10], T);
26    assertEq(obj.length, 11);
27    var K = T + 9;
28    obj[K] = K;
29    assertEq(obj[K], K);
30    assertEq(obj.length, 12);
31    obj[K + 1] = obj;
32    assertEq(obj[K + 1], obj);
33    assertEq(obj.length, 13);
34}
35
36for (var i = 0; i < 10; i++) {
37    testBadSetElems([], -1);
38    testDenseSets(2);
39}
40
41