michael@0: // vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: michael@0: function fillDense(a) { michael@0: } michael@0: michael@0: function testDenseUKeyUArray(a, key) { michael@0: a.push(function () { return this[3]; }); michael@0: a.push(function () { return this[4]; }); michael@0: a.push(function() { return this[5]; }); michael@0: a.push(20); michael@0: a.push("hi"); michael@0: a.push(500); michael@0: assertEq(a[key](), 20); michael@0: assertEq(a[key + 1](), "hi"); michael@0: assertEq(a[key + 2](), 500); michael@0: } michael@0: michael@0: function testDenseVKeyUArray(a) { michael@0: a.push(function () { return this[3]; }); michael@0: a.push(function () { return this[4]; }); michael@0: a.push(function() { return this[5]; }); michael@0: a.push(20); michael@0: a.push("hi"); michael@0: a.push(500); michael@0: var key = a.length & 1; michael@0: assertEq(a[key](), 20); michael@0: assertEq(a[(key + 1) & 3](), "hi"); michael@0: assertEq(a[(key + 2) & 3](), 500); michael@0: } michael@0: michael@0: function testDenseKKeyUArray(a, key) { michael@0: a.push(function () { return this[3]; }); michael@0: a.push(function () { return this[4]; }); michael@0: a.push(function() { return this[5]; }); michael@0: a.push(20); michael@0: a.push("hi"); michael@0: a.push(500); michael@0: assertEq(a[0](), 20); michael@0: assertEq(a[1](), "hi"); michael@0: assertEq(a[2](), 500); michael@0: } michael@0: michael@0: function testDenseUKeyVArray(key) { michael@0: var a = [function () { return this[3]; }, michael@0: function () { return this[4]; }, michael@0: function() { return this[5]; }, michael@0: 20, michael@0: "hi", michael@0: 500]; michael@0: assertEq(a[key](), 20); michael@0: assertEq(a[key + 1](), "hi"); michael@0: assertEq(a[key + 2](), 500); michael@0: } michael@0: michael@0: function testDenseVKeyVArray() { michael@0: var a = [function () { return this[3]; }, michael@0: function () { return this[4]; }, michael@0: function() { return this[5]; }, michael@0: 20, michael@0: "hi", michael@0: 500]; michael@0: var key = a.length & 1; michael@0: assertEq(a[key](), 20); michael@0: assertEq(a[(key + 1) & 3](), "hi"); michael@0: assertEq(a[(key + 2) & 3](), 500); michael@0: } michael@0: michael@0: function testDenseKKeyVArray() { michael@0: var a = [function () { return this[3]; }, michael@0: function () { return this[4]; }, michael@0: function() { return this[5]; }, michael@0: 20, michael@0: "hi", michael@0: 500]; michael@0: assertEq(a[0](), 20); michael@0: assertEq(a[1](), "hi"); michael@0: assertEq(a[2](), 500); michael@0: } michael@0: michael@0: for (var i = 0; i < 5; i++) { michael@0: testDenseUKeyUArray([], 0); michael@0: testDenseVKeyUArray([]); michael@0: testDenseKKeyUArray([]); michael@0: testDenseUKeyVArray(0); michael@0: testDenseVKeyVArray(); michael@0: testDenseKKeyVArray(); michael@0: } michael@0: michael@0: