| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 })(); | 1142 })(); |
| 1143 | 1143 |
| 1144 | 1144 |
| 1145 (function TestNonStrictFunctionCallerPillSimple() { | 1145 (function TestNonStrictFunctionCallerPillSimple() { |
| 1146 function return_my_caller() { | 1146 function return_my_caller() { |
| 1147 return return_my_caller.caller; | 1147 return return_my_caller.caller; |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 function strict() { | 1150 function strict() { |
| 1151 "use strict"; | 1151 "use strict"; |
| 1152 // Returning result via local variable to avoid tail call optimization. | 1152 // Returning result via local variable to avoid tail call elimination. |
| 1153 var res = return_my_caller(); | 1153 var res = return_my_caller(); |
| 1154 return res; | 1154 return res; |
| 1155 } | 1155 } |
| 1156 assertSame(null, strict()); | 1156 assertSame(null, strict()); |
| 1157 | 1157 |
| 1158 function non_strict() { | 1158 function non_strict() { |
| 1159 return return_my_caller(); | 1159 return return_my_caller(); |
| 1160 } | 1160 } |
| 1161 assertSame(non_strict(), non_strict); | 1161 assertSame(non_strict(), non_strict); |
| 1162 })(); | 1162 })(); |
| 1163 | 1163 |
| 1164 | 1164 |
| 1165 (function TestNonStrictFunctionCallerPill() { | 1165 (function TestNonStrictFunctionCallerPill() { |
| 1166 function strict(n) { | 1166 function strict(n) { |
| 1167 "use strict"; | 1167 "use strict"; |
| 1168 // Returning result via local variable to avoid tail call optimization. | 1168 // Returning result via local variable to avoid tail call elimination. |
| 1169 var res = non_strict(n); | 1169 var res = non_strict(n); |
| 1170 return res; | 1170 return res; |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 function recurse(n, then) { | 1173 function recurse(n, then) { |
| 1174 if (n > 0) { | 1174 if (n > 0) { |
| 1175 return recurse(n - 1, then); | 1175 return recurse(n - 1, then); |
| 1176 } else { | 1176 } else { |
| 1177 return then(); | 1177 return then(); |
| 1178 } | 1178 } |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 function non_strict(n) { | 1181 function non_strict(n) { |
| 1182 return recurse(n, function() { return non_strict.caller; }); | 1182 return recurse(n, function() { return non_strict.caller; }); |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 function test(n) { | 1185 function test(n) { |
| 1186 return recurse(n, function() { return strict(n); }); | 1186 return recurse(n, function() { return strict(n); }); |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 for (var i = 0; i < 10; i ++) { | 1189 for (var i = 0; i < 10; i ++) { |
| 1190 assertSame(null, test(i)); | 1190 assertSame(null, test(i)); |
| 1191 } | 1191 } |
| 1192 })(); | 1192 })(); |
| 1193 | 1193 |
| 1194 | 1194 |
| 1195 (function TestNonStrictFunctionCallerDescriptorPill() { | 1195 (function TestNonStrictFunctionCallerDescriptorPill() { |
| 1196 function strict(n) { | 1196 function strict(n) { |
| 1197 "use strict"; | 1197 "use strict"; |
| 1198 // Returning result via local variable to avoid tail call optimization. | 1198 // Returning result via local variable to avoid tail call elimination. |
| 1199 var res = non_strict(n); | 1199 var res = non_strict(n); |
| 1200 return res; | 1200 return res; |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 function recurse(n, then) { | 1203 function recurse(n, then) { |
| 1204 if (n > 0) { | 1204 if (n > 0) { |
| 1205 return recurse(n - 1, then); | 1205 return recurse(n - 1, then); |
| 1206 } else { | 1206 } else { |
| 1207 return then(); | 1207 return then(); |
| 1208 } | 1208 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1222 assertSame(null, test(i)); | 1222 assertSame(null, test(i)); |
| 1223 } | 1223 } |
| 1224 })(); | 1224 })(); |
| 1225 | 1225 |
| 1226 | 1226 |
| 1227 (function TestStrictModeEval() { | 1227 (function TestStrictModeEval() { |
| 1228 "use strict"; | 1228 "use strict"; |
| 1229 eval("var eval_local = 10;"); | 1229 eval("var eval_local = 10;"); |
| 1230 assertThrows(function() { return eval_local; }, ReferenceError); | 1230 assertThrows(function() { return eval_local; }, ReferenceError); |
| 1231 })(); | 1231 })(); |
| OLD | NEW |