js/src/jit-test/tests/ion/bug861165.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 // IM has the following fastpaths:
michael@0 2 // - constant index (constant)
michael@0 3 // - need negative int check (neg)
michael@0 4 // - needs hole check (hole)
michael@0 5 // So to test everything we have to do:
michael@0 6 // constant | neg | hole
michael@0 7 // test 1: 0 0 0
michael@0 8 // test 2: 1 0 0
michael@0 9 // test 3: 0 1 0
michael@0 10 // test 4: 1 1 0
michael@0 11 // test 5: 0 0 1
michael@0 12 // test 6: 1 0 1
michael@0 13 // test 7: 0 1 1
michael@0 14 // test 8: 1 1 1
michael@0 15
michael@0 16 function test1(index, a) {
michael@0 17 if (index < 0)
michael@0 18 index = -index
michael@0 19 return index in a;
michael@0 20 }
michael@0 21 assertEq(test1(1, [1,2]), true);
michael@0 22
michael@0 23 function test2(a) {
michael@0 24 return 0 in a;
michael@0 25 }
michael@0 26 assertEq(test2([1,2]), true);
michael@0 27
michael@0 28 function test3(index, a) {
michael@0 29 return index in a;
michael@0 30 }
michael@0 31
michael@0 32 var arr3 = [];
michael@0 33 arr3["-1073741828"] = 17;
michael@0 34 assertEq(test3(-1073741828, arr3), true);
michael@0 35
michael@0 36 function test4(a) {
michael@0 37 return -1073741828 in a;
michael@0 38 }
michael@0 39 assertEq(test4(arr3), true);
michael@0 40
michael@0 41
michael@0 42 function test5(index, a) {
michael@0 43 if (index < 0)
michael@0 44 index = -index
michael@0 45 return index in a;
michael@0 46 }
michael@0 47 var arr5 = [];
michael@0 48 arr5[0] = 1
michael@0 49 arr5[1] = 1
michael@0 50 arr5[2] = 1
michael@0 51 arr5[4] = 1
michael@0 52 assertEq(test5(1, arr5), true);
michael@0 53 assertEq(test5(3, arr5), false);
michael@0 54
michael@0 55 function test7a(a) {
michael@0 56 return 3 in a;
michael@0 57 }
michael@0 58 function test7b(a) {
michael@0 59 return 4 in a;
michael@0 60 }
michael@0 61 assertEq(test7a(arr5), false);
michael@0 62 assertEq(test7b(arr5), true);
michael@0 63
michael@0 64 function test8(index, a) {
michael@0 65 return index in a;
michael@0 66 }
michael@0 67 arr5["-1073741828"] = 17;
michael@0 68 assertEq(test8(-1073741828, arr5), true);
michael@0 69 assertEq(test8(3, arr5), false);
michael@0 70 assertEq(test8(0, arr5), true);
michael@0 71
michael@0 72 function test9a(a) {
michael@0 73 return 0 in a;
michael@0 74 }
michael@0 75 function test9b(a) {
michael@0 76 return 3 in a;
michael@0 77 }
michael@0 78 function test9c(a) {
michael@0 79 return -1073741828 in a;
michael@0 80 }
michael@0 81 assertEq(test9a(arr5), true);
michael@0 82 assertEq(test9b(arr5), false);
michael@0 83 assertEq(test9c(arr5), true);

mercurial