OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/cctest/compiler/function-tester.h" | 5 #include "test/cctest/compiler/function-tester.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 387 |
388 TEST(GlobalLoad) { | 388 TEST(GlobalLoad) { |
389 FunctionTester T("(function() { return g; })"); | 389 FunctionTester T("(function() { return g; })"); |
390 | 390 |
391 T.CheckThrows(T.undefined(), T.undefined()); | 391 T.CheckThrows(T.undefined(), T.undefined()); |
392 CompileRun("var g = 23;"); | 392 CompileRun("var g = 23;"); |
393 T.CheckCall(T.Val(23)); | 393 T.CheckCall(T.Val(23)); |
394 } | 394 } |
395 | 395 |
396 | 396 |
397 TEST(GlobalStoreSloppy) { | |
398 FLAG_legacy_const = true; | |
399 FunctionTester T("(function(a,b) { g = a + b; return g; })"); | |
400 | |
401 T.CheckCall(T.Val(33), T.Val(22), T.Val(11)); | |
402 CompileRun("delete g"); | |
403 CompileRun("const g = 23"); | |
404 T.CheckCall(T.Val(23), T.Val(55), T.Val(44)); | |
405 } | |
406 | |
407 | |
408 TEST(GlobalStoreStrict) { | 397 TEST(GlobalStoreStrict) { |
409 FunctionTester T("(function(a,b) { 'use strict'; g = a + b; return g; })"); | 398 FunctionTester T("(function(a,b) { 'use strict'; g = a + b; return g; })"); |
410 | 399 |
411 T.CheckThrows(T.Val(22), T.Val(11)); | 400 T.CheckThrows(T.Val(22), T.Val(11)); |
412 CompileRun("var g = 'a global variable';"); | 401 CompileRun("var g = 'a global variable';"); |
413 T.CheckCall(T.Val(33), T.Val(22), T.Val(11)); | 402 T.CheckCall(T.Val(33), T.Val(22), T.Val(11)); |
414 } | 403 } |
415 | 404 |
416 | 405 |
417 TEST(ContextLoad) { | 406 TEST(ContextLoad) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 "})"; | 525 "})"; |
537 FunctionTester T(src); | 526 FunctionTester T(src); |
538 | 527 |
539 T.CheckCall(T.Val(65), T.Val(23), T.Val(42)); | 528 T.CheckCall(T.Val(65), T.Val(23), T.Val(42)); |
540 T.CheckCall(T.Val("ab"), T.Val("a"), T.Val("b")); | 529 T.CheckCall(T.Val("ab"), T.Val("a"), T.Val("b")); |
541 } | 530 } |
542 | 531 |
543 } // namespace compiler | 532 } // namespace compiler |
544 } // namespace internal | 533 } // namespace internal |
545 } // namespace v8 | 534 } // namespace v8 |
OLD | NEW |