js/src/jit-test/tests/ion/inlining/array-push.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 function test1() {
michael@0 2 function push(arr, x) {
michael@0 3 return arr.push(x);
michael@0 4 }
michael@0 5 var arr = [];
michael@0 6 for (var i=0; i<100; i++) {
michael@0 7 assertEq(push(arr, i), i + 1);
michael@0 8 }
michael@0 9 }
michael@0 10 test1();
michael@0 11
michael@0 12 function test2() {
michael@0 13 var arr;
michael@0 14 for (var i=0; i<60; i++) {
michael@0 15 arr = [];
michael@0 16 assertEq(arr.push(3.3), 1);
michael@0 17 assertEq(arr.push(undefined), 2);
michael@0 18 assertEq(arr.push(true), 3);
michael@0 19 assertEq(arr.push(Math), 4);
michael@0 20 assertEq(arr.toString(), "3.3,,true,[object Math]");
michael@0 21 }
michael@0 22 }
michael@0 23 test2();
michael@0 24
michael@0 25 function test3() {
michael@0 26 function push(arr, v) {
michael@0 27 arr.push(v);
michael@0 28 }
michael@0 29 for (var i=0; i<60; i++) {
michael@0 30 var arr = [];
michael@0 31 push(arr, null);
michael@0 32 push(arr, 3.14);
michael@0 33 push(arr, {});
michael@0 34 assertEq(arr.toString(), ",3.14,[object Object]");
michael@0 35 }
michael@0 36 }
michael@0 37 test3();

mercurial