| OLD | NEW | 
|     1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |     1 // Copyright 2007-2008 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 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1176   { |  1176   { | 
|  1177     SimpleContext context; |  1177     SimpleContext context; | 
|  1178  |  1178  | 
|  1179     context.Check("'use strict'; o; const o = 10", EXPECT_EXCEPTION); |  1179     context.Check("'use strict'; o; const o = 10", EXPECT_EXCEPTION); | 
|  1180  |  1180  | 
|  1181     for (int i = 0; i < 100; i++) { |  1181     for (int i = 0; i < 100; i++) { | 
|  1182       context.Check("o.prototype", EXPECT_EXCEPTION); |  1182       context.Check("o.prototype", EXPECT_EXCEPTION); | 
|  1183     } |  1183     } | 
|  1184   } |  1184   } | 
|  1185 } |  1185 } | 
 |  1186  | 
 |  1187  | 
 |  1188 TEST(Regress3941) { | 
 |  1189   i::FLAG_harmony_scoping = true; | 
 |  1190   i::FLAG_allow_natives_syntax = true; | 
 |  1191  | 
 |  1192   HandleScope handle_scope(CcTest::isolate()); | 
 |  1193  | 
 |  1194   { | 
 |  1195     SimpleContext context; | 
 |  1196     context.Check("function f() { x = 1; }", EXPECT_RESULT, | 
 |  1197                   Undefined(CcTest::isolate())); | 
 |  1198     context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 
 |  1199   } | 
 |  1200  | 
 |  1201  | 
 |  1202   { | 
 |  1203     // Train ICs. | 
 |  1204     SimpleContext context; | 
 |  1205     context.Check("function f() { x = 1; }", EXPECT_RESULT, | 
 |  1206                   Undefined(CcTest::isolate())); | 
 |  1207     for (int i = 0; i < 4; i++) { | 
 |  1208       context.Check("f(); x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); | 
 |  1209     } | 
 |  1210     context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 
 |  1211   } | 
 |  1212  | 
 |  1213  | 
 |  1214   { | 
 |  1215     // Optimize. | 
 |  1216     SimpleContext context; | 
 |  1217     context.Check("function f() { x = 1; }", EXPECT_RESULT, | 
 |  1218                   Undefined(CcTest::isolate())); | 
 |  1219     for (int i = 0; i < 4; i++) { | 
 |  1220       context.Check("f(); x", EXPECT_RESULT, Number::New(CcTest::isolate(), 1)); | 
 |  1221     } | 
 |  1222     context.Check("%OptimizeFunctionOnNextCall(f); f(); x", EXPECT_RESULT, | 
 |  1223                   Number::New(CcTest::isolate(), 1)); | 
 |  1224  | 
 |  1225     context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 
 |  1226   } | 
 |  1227 } | 
 |  1228  | 
 |  1229  | 
 |  1230 TEST(Regress3941_Reads) { | 
 |  1231   i::FLAG_harmony_scoping = true; | 
 |  1232   i::FLAG_allow_natives_syntax = true; | 
 |  1233  | 
 |  1234   HandleScope handle_scope(CcTest::isolate()); | 
 |  1235  | 
 |  1236   { | 
 |  1237     SimpleContext context; | 
 |  1238     context.Check("function f() { return x; }", EXPECT_RESULT, | 
 |  1239                   Undefined(CcTest::isolate())); | 
 |  1240     context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 
 |  1241   } | 
 |  1242  | 
 |  1243  | 
 |  1244   { | 
 |  1245     // Train ICs. | 
 |  1246     SimpleContext context; | 
 |  1247     context.Check("function f() { return x; }", EXPECT_RESULT, | 
 |  1248                   Undefined(CcTest::isolate())); | 
 |  1249     for (int i = 0; i < 4; i++) { | 
 |  1250       context.Check("f()", EXPECT_EXCEPTION); | 
 |  1251     } | 
 |  1252     context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 
 |  1253   } | 
 |  1254  | 
 |  1255  | 
 |  1256   { | 
 |  1257     // Optimize. | 
 |  1258     SimpleContext context; | 
 |  1259     context.Check("function f() { return x; }", EXPECT_RESULT, | 
 |  1260                   Undefined(CcTest::isolate())); | 
 |  1261     for (int i = 0; i < 4; i++) { | 
 |  1262       context.Check("f()", EXPECT_EXCEPTION); | 
 |  1263     } | 
 |  1264     context.Check("%OptimizeFunctionOnNextCall(f);", EXPECT_RESULT, | 
 |  1265                   Undefined(CcTest::isolate())); | 
 |  1266  | 
 |  1267     context.Check("'use strict'; f(); let x = 2; x", EXPECT_EXCEPTION); | 
 |  1268   } | 
 |  1269 } | 
| OLD | NEW |