js/src/jit-test/tests/ion/testInArray.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 var dense = [1, 2, 3];
michael@0 3 var denseHoles = [1, , 3];
michael@0 4 var result = 0;
michael@0 5
michael@0 6 for (var i = 0; i < 70; i++) {
michael@0 7 if (i in dense) result += 1;
michael@0 8 if (1 in dense) result += 2;
michael@0 9 if (3 in dense) result += 3;
michael@0 10 if (-1000 in dense) result += 4;
michael@0 11 if (i in denseHoles) result += 5;
michael@0 12 if (1 in denseHoles) result += 6;
michael@0 13 }
michael@0 14
michael@0 15 assertEq(result, 153);
michael@0 16 }
michael@0 17 test1();
michael@0 18
michael@0 19 function test2() {
michael@0 20 var a = [1, 2, 3];
michael@0 21
michael@0 22 for (var i = 0; i < 70; i++) {
michael@0 23 assertEq(-0 in a, true);
michael@0 24 assertEq(Math.sqrt(4) in a, true);
michael@0 25 assertEq(1.9 in a, false);
michael@0 26 assertEq(NaN in a, false);
michael@0 27 assertEq(Infinity in a, false);
michael@0 28 }
michael@0 29 }
michael@0 30 test2();
michael@0 31
michael@0 32 function test3() {
michael@0 33 var a = [1, , 3];
michael@0 34
michael@0 35 for (var i = 0; i < 70; i++) {
michael@0 36 if (i == 60)
michael@0 37 Object.prototype[1] = null;
michael@0 38 assertEq(1 in a, i >= 60);
michael@0 39 }
michael@0 40 }
michael@0 41 test3();

mercurial