js/src/jit-test/tests/jaeger/testDenseCallElem.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial