| 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 "src/compiler/ast-loop-assignment-analyzer.h" | 5 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 6 #include "src/parser.h" | 6 #include "src/parser.h" |
| 7 #include "src/rewriter.h" | 7 #include "src/rewriter.h" |
| 8 #include "src/scopes.h" | 8 #include "src/scopes.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 CHECK(var); | 52 CHECK(var); |
| 53 | 53 |
| 54 if (var->location() == VariableLocation::UNALLOCATED) { | 54 if (var->location() == VariableLocation::UNALLOCATED) { |
| 55 CHECK_EQ(0, expected); | 55 CHECK_EQ(0, expected); |
| 56 } else { | 56 } else { |
| 57 CHECK(var->IsStackAllocated()); | 57 CHECK(var->IsStackAllocated()); |
| 58 CHECK_EQ(expected, result->GetAssignmentCountForTesting(scope, var)); | 58 CHECK_EQ(expected, result->GetAssignmentCountForTesting(scope, var)); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 }; | 61 }; |
| 62 } | 62 } // namespace |
| 63 | 63 |
| 64 | 64 |
| 65 TEST(SimpleLoop1) { | 65 TEST(SimpleLoop1) { |
| 66 TestHelper f("var x = 0; while (x) ;"); | 66 TestHelper f("var x = 0; while (x) ;"); |
| 67 | 67 |
| 68 f.CheckLoopAssignedCount(0, "x"); | 68 f.CheckLoopAssignedCount(0, "x"); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 TEST(SimpleLoop2) { | 72 TEST(SimpleLoop2) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 " while (1) z++;" | 286 " while (1) z++;" |
| 287 " }" | 287 " }" |
| 288 "}" | 288 "}" |
| 289 "w;"); | 289 "w;"); |
| 290 | 290 |
| 291 f.CheckLoopAssignedCount(1, "x"); | 291 f.CheckLoopAssignedCount(1, "x"); |
| 292 f.CheckLoopAssignedCount(3, "y"); | 292 f.CheckLoopAssignedCount(3, "y"); |
| 293 f.CheckLoopAssignedCount(5, "z"); | 293 f.CheckLoopAssignedCount(5, "z"); |
| 294 f.CheckLoopAssignedCount(0, "w"); | 294 f.CheckLoopAssignedCount(0, "w"); |
| 295 } | 295 } |
| OLD | NEW |