js/src/jit-test/tests/ion/bug813784.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 /* Test an inlined argument returns the arguments from the right function */
michael@0 2 function get_arg_2() { return arguments[2]; }
michael@0 3 function test() { return get_arg_2(1,2,3); }
michael@0 4
michael@0 5 assertEq(test("a","b","c"), 3);
michael@0 6 assertEq(test("a","b","c"), 3);
michael@0 7
michael@0 8 /* Test the right length of the argument vector gets returned */
michael@0 9 function arg_len() { return arguments.length; }
michael@0 10 function test2() { return arg_len(1,2,3); }
michael@0 11
michael@0 12 assertEq(test2("a","b","c","d"), 3);
michael@0 13 assertEq(test2("a","b","c","d"), 3);
michael@0 14
michael@0 15 /* Test returning the argument vector */
michael@0 16 function get_arg() { return arguments; }
michael@0 17 function test3() { return get_arg(1,2,3) }
michael@0 18
michael@0 19 var arg = test3("a","b","c","d","e");
michael@0 20 assertEq(arg.length, 3);
michael@0 21 assertEq(arg[0], 1);
michael@0 22 assertEq(arg[1], 2);
michael@0 23 assertEq(arg[2], 3);
michael@0 24 var arg = test3("a","b","c","d","e");
michael@0 25 assertEq(arg.length, 3);
michael@0 26 assertEq(arg[0], 1);
michael@0 27 assertEq(arg[1], 2);
michael@0 28 assertEq(arg[2], 3);
michael@0 29
michael@0 30 /* Test funapply with arguments */
michael@0 31 function return0(a, b, c) { return 0; }
michael@0 32 function funapply() { return return0.apply({}, arguments); }
michael@0 33 function test4() { return funapply(1,2,3) }
michael@0 34
michael@0 35 assertEq(test4("a","b","c","d","e"), 0);
michael@0 36 assertEq(test4("a","b","c","d","e"), 0);
michael@0 37
michael@0 38 /* Test if funapply gets the right arguments */
michael@0 39 function apply3(a, b, c) {
michael@0 40 assertEq(a,1)
michael@0 41 assertEq(b,2)
michael@0 42 assertEq(c,3)
michael@0 43 }
michael@0 44 function funapply2() { return apply3.apply({}, arguments); }
michael@0 45 function test5() { return funapply2(1,2,3) }
michael@0 46
michael@0 47 test5("a","b","c","d","e");
michael@0 48 test5("a","b","c","d","e");
michael@0 49
michael@0 50 /* Test funapply when argument vector has less args than callee and callee known */
michael@0 51 function apply_fun1(a, b, c) { assertEq(c, undefined) }
michael@0 52 function funapply3() { return apply_fun1.apply({}, arguments); }
michael@0 53 function test7() { return funapply3(1,2) }
michael@0 54
michael@0 55 test7("a","b","c","d","e");
michael@0 56 test7("a","b","c","d","e");
michael@0 57
michael@0 58 /* Test funapply when argument vector has less args than callee and callee unknown */
michael@0 59 var fun;
michael@0 60 function apply_fun2(a, b, c) { assertEq(c, undefined) }
michael@0 61 function funapply4() { return fun.apply({}, arguments); }
michael@0 62 function test8() { return funapply4(1,2) }
michael@0 63
michael@0 64 fun = apply_fun1;
michael@0 65 test8("a","b","c","d","e");
michael@0 66 fun = apply_fun2;
michael@0 67 test8("a","b","c","d","e");
michael@0 68 fun = apply_fun1;
michael@0 69 test8("a","b","c","d","e");
michael@0 70 fun = apply_fun2;
michael@0 71 test8("a","b","c","d","e");
michael@0 72
michael@0 73 ////////////
michael@0 74
michael@0 75 function dumpArgs(i) { if (i == 90) return funapply5.arguments.length; return [i]; }
michael@0 76 function funapply5() { return dumpArgs.apply({}, arguments); }
michael@0 77 function test9(i) { return funapply5(i); }
michael@0 78
michael@0 79 assertEq(test9(89)[0], 89);
michael@0 80 assertEq(test9(90), 1);
michael@0 81
michael@0 82 /////////////
michael@0 83
michael@0 84 function notinlined() {
michael@0 85 assertEq(arguments[0], 4);
michael@0 86 assertEq(arguments[1], 5);
michael@0 87 assertEq(arguments[2], 6);
michael@0 88 }
michael@0 89
michael@0 90 function inline2(a) { return notinlined(4,5,6); }
michael@0 91 function inline() { return inline2(1,2,3); }
michael@0 92 function base1() { return inline(-1,-2,-3); }
michael@0 93
michael@0 94 base1(10,11,12);
michael@0 95 base1(10,11,12);
michael@0 96
michael@0 97 ////////////////
michael@0 98
michael@0 99 function inlined(a) {
michael@0 100 if (a == 11) {
michael@0 101 a = undefined;
michael@0 102 return arguments;
michael@0 103 }
michael@0 104 }
michael@0 105
michael@0 106 function inline4(a) { return inlined(a,5,6); }
michael@0 107 function inline3(a) { return inline4(a,2,3); }
michael@0 108 function base2(a) { return inline3(a,-2,-3); }
michael@0 109
michael@0 110 var args = base2(10,11,12);
michael@0 111 assertEq(args, undefined);
michael@0 112 var args = base2(11,11,12);
michael@0 113 assertEq(args[0], undefined);
michael@0 114 assertEq(args[1], 5);
michael@0 115 assertEq(args[2], 6);
michael@0 116 var args = base2(10,11,12);
michael@0 117 assertEq(args, undefined);
michael@0 118 var args = base2(11,11,12);
michael@0 119 assertEq(args[0], undefined);
michael@0 120 assertEq(args[1], 5);
michael@0 121 assertEq(args[2], 6);
michael@0 122
michael@0 123 //////////////////
michael@0 124
michael@0 125 function arg_len2() { assertEq(arguments.length, 4); }
michael@0 126 function bailing_arg_len(a) {
michael@0 127 if (a == 90) {
michael@0 128 bailout();
michael@0 129 arg_len.apply({}, arguments);
michael@0 130 }
michael@0 131 assertEq(arguments.length, 4);
michael@0 132 return arguments;
michael@0 133 }
michael@0 134 function test10(i) { return bailing_arg_len(i,2,3,4); }
michael@0 135
michael@0 136 var args = test10(1, "b");
michael@0 137 assertEq(args.length, 4)
michael@0 138 assertEq(args[0], 1)
michael@0 139 assertEq(args[1], 2)
michael@0 140 assertEq(args[2], 3)
michael@0 141 assertEq(args[3], 4)
michael@0 142
michael@0 143 var args = test10(90, 'b');
michael@0 144 assertEq(args.length, 4)
michael@0 145 assertEq(args[0], 90)
michael@0 146 assertEq(args[1], 2)
michael@0 147 assertEq(args[2], 3)
michael@0 148 assertEq(args[3], 4)
michael@0 149
michael@0 150 ////////////
michael@0 151
michael@0 152 function dumpArgs11(i) { return funapply11.arguments; eval(""); }
michael@0 153 function funapply11(i) { return dumpArgs11(i); }
michael@0 154 function test11(i) { return funapply11(i); }
michael@0 155
michael@0 156 assertEq(test11(89)[0], 89);
michael@0 157 assertEq(test11(90)[0], 90);
michael@0 158
michael@0 159 ////////////
michael@0 160
michael@0 161 function dumpArgs12(i) { if (i == 90) return funapply12.arguments; return [i]; }
michael@0 162 function noion12(i) { return dumpArgs12(i); eval(""); }
michael@0 163 function funapply12(i) { return noion12(i); }
michael@0 164 function test12(i) { return funapply12(i); }
michael@0 165
michael@0 166 assertEq(test12("89")[0], "89");
michael@0 167 assertEq(test12("90")[0], "90");
michael@0 168
michael@0 169 ////////////
michael@0 170
michael@0 171 function f13(i) { if (i == "90") return f13.arguments; return [i]; }
michael@0 172 function test13(i,b) { return f13(i,b); }
michael@0 173
michael@0 174 assertEq(test13("89", 1)[0], "89");
michael@0 175 assertEq(test13("90", 2)[1], 2);
michael@0 176
michael@0 177 ///////////
michael@0 178
michael@0 179 function noion14(i) { if (i == 2) { return funapply14.arguments; } return [i]; eval(""); }
michael@0 180 function funapply14(i) { if (i == 90) { i = "2"; } return noion14(i); }
michael@0 181 function test14(i) { return funapply14(i); }
michael@0 182
michael@0 183 assertEq(test14("89")[0], "89");
michael@0 184 assertEq(test14("90")[0], "2");

mercurial