testDenseCallElem.js (2257B)
1 // vim: set ts=8 sts=4 et sw=4 tw=99: 2 3 function fillDense(a) { 4 } 5 6 function testDenseUKeyUArray(a, key) { 7 a.push(function () { return this[3]; }); 8 a.push(function () { return this[4]; }); 9 a.push(function() { return this[5]; }); 10 a.push(20); 11 a.push("hi"); 12 a.push(500); 13 assertEq(a[key](), 20); 14 assertEq(a[key + 1](), "hi"); 15 assertEq(a[key + 2](), 500); 16 } 17 18 function testDenseVKeyUArray(a) { 19 a.push(function () { return this[3]; }); 20 a.push(function () { return this[4]; }); 21 a.push(function() { return this[5]; }); 22 a.push(20); 23 a.push("hi"); 24 a.push(500); 25 var key = a.length & 1; 26 assertEq(a[key](), 20); 27 assertEq(a[(key + 1) & 3](), "hi"); 28 assertEq(a[(key + 2) & 3](), 500); 29 } 30 31 function testDenseKKeyUArray(a, key) { 32 a.push(function () { return this[3]; }); 33 a.push(function () { return this[4]; }); 34 a.push(function() { return this[5]; }); 35 a.push(20); 36 a.push("hi"); 37 a.push(500); 38 assertEq(a[0](), 20); 39 assertEq(a[1](), "hi"); 40 assertEq(a[2](), 500); 41 } 42 43 function testDenseUKeyVArray(key) { 44 var a = [function () { return this[3]; }, 45 function () { return this[4]; }, 46 function() { return this[5]; }, 47 20, 48 "hi", 49 500]; 50 assertEq(a[key](), 20); 51 assertEq(a[key + 1](), "hi"); 52 assertEq(a[key + 2](), 500); 53 } 54 55 function testDenseVKeyVArray() { 56 var a = [function () { return this[3]; }, 57 function () { return this[4]; }, 58 function() { return this[5]; }, 59 20, 60 "hi", 61 500]; 62 var key = a.length & 1; 63 assertEq(a[key](), 20); 64 assertEq(a[(key + 1) & 3](), "hi"); 65 assertEq(a[(key + 2) & 3](), 500); 66 } 67 68 function testDenseKKeyVArray() { 69 var a = [function () { return this[3]; }, 70 function () { return this[4]; }, 71 function() { return this[5]; }, 72 20, 73 "hi", 74 500]; 75 assertEq(a[0](), 20); 76 assertEq(a[1](), "hi"); 77 assertEq(a[2](), 500); 78 } 79 80 for (var i = 0; i < 5; i++) { 81 testDenseUKeyUArray([], 0); 82 testDenseVKeyUArray([]); 83 testDenseKKeyUArray([]); 84 testDenseUKeyVArray(0); 85 testDenseVKeyVArray(); 86 testDenseKKeyVArray(); 87 }