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 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 | 1153 |
1154 | 1154 |
1155 (function TestNonStrictFunctionCallerPill() { | 1155 (function TestNonStrictFunctionCallerPill() { |
1156 function strict(n) { | 1156 function strict(n) { |
1157 "use strict"; | 1157 "use strict"; |
1158 non_strict(n); | 1158 non_strict(n); |
1159 } | 1159 } |
1160 | 1160 |
1161 function recurse(n, then) { | 1161 function recurse(n, then) { |
1162 if (n > 0) { | 1162 if (n > 0) { |
1163 recurse(n - 1); | 1163 recurse(n - 1, then); |
1164 } else { | 1164 } else { |
1165 return then(); | 1165 return then(); |
1166 } | 1166 } |
1167 } | 1167 } |
1168 | 1168 |
1169 function non_strict(n) { | 1169 function non_strict(n) { |
1170 recurse(n, function() { non_strict.caller; }); | 1170 recurse(n, function() { non_strict.caller; }); |
1171 } | 1171 } |
1172 | 1172 |
1173 function test(n) { | 1173 function test(n) { |
1174 try { | 1174 try { |
1175 recurse(n, function() { strict(n); }); | 1175 recurse(n, function() { strict(n); }); |
1176 } catch(e) { | 1176 } catch(e) { |
1177 return e instanceof TypeError; | 1177 return e instanceof TypeError; |
1178 } | 1178 } |
1179 return false; | 1179 return false; |
1180 } | 1180 } |
1181 | 1181 |
1182 for (var i = 0; i < 10; i ++) { | 1182 for (var i = 0; i < 10; i ++) { |
1183 assertEquals(test(i), true); | 1183 assertEquals(test(i), true); |
1184 } | 1184 } |
1185 })(); | 1185 })(); |
1186 | 1186 |
1187 | 1187 |
1188 (function TestStrictModeEval() { | 1188 (function TestStrictModeEval() { |
1189 "use strict"; | 1189 "use strict"; |
1190 eval("var eval_local = 10;"); | 1190 eval("var eval_local = 10;"); |
1191 assertThrows(function() { return eval_local; }, ReferenceError); | 1191 assertThrows(function() { return eval_local; }, ReferenceError); |
1192 })(); | 1192 })(); |
OLD | NEW |