| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
| 6 | 6 |
| 7 import 'helper.dart' show check; | 7 import 'helper.dart' show check; |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 test('for loop', () { | 10 test('for loop', () { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 main() { | 60 main() { |
| 61 var sum = 0; | 61 var sum = 0; |
| 62 for (var a in [1, 2, 3]) { | 62 for (var a in [1, 2, 3]) { |
| 63 sum += a; | 63 sum += a; |
| 64 } | 64 } |
| 65 return sum; | 65 return sum; |
| 66 }'''; | 66 }'''; |
| 67 // This is the same test as above, but by enabling type inference | 67 // This is the same test as above, but by enabling type inference |
| 68 // we allow the compiler to detect that it can iterate over the | 68 // we allow the compiler to detect that it can iterate over the |
| 69 // array using indexing. | 69 // array using indexing. |
| 70 return check(code, disableTypeInference: false); | 70 return check(code, disableTypeInference: false, useKernelInSsa: true); |
| 71 }); | 71 }); |
| 72 | 72 |
| 73 test('for-in loop top-level variable', () { | 73 test('for-in loop top-level variable', () { |
| 74 String code = ''' | 74 String code = ''' |
| 75 var a = 0; | 75 var a = 0; |
| 76 main() { | 76 main() { |
| 77 var sum = 0; | 77 var sum = 0; |
| 78 for (a in [1, 2, 3]) { | 78 for (a in [1, 2, 3]) { |
| 79 sum += a; | 79 sum += a; |
| 80 } | 80 } |
| 81 return sum; | 81 return sum; |
| 82 }'''; | 82 }'''; |
| 83 return check(code, disableTypeInference: false); | 83 return check(code, disableTypeInference: false, useKernelInSsa: true); |
| 84 }); | 84 }); |
| 85 | 85 |
| 86 test('for loop with break to label', () { | 86 test('for loop with break to label', () { |
| 87 String code = ''' | 87 String code = ''' |
| 88 var a = 0; | 88 var a = 0; |
| 89 main() { | 89 main() { |
| 90 var sum = 0; | 90 var sum = 0; |
| 91 outer: for (a in [1, 2, 3]) { | 91 outer: for (a in [1, 2, 3]) { |
| 92 for (int i = 0; i < 10; i++) { | 92 for (int i = 0; i < 10; i++) { |
| 93 sum += a; | 93 sum += a; |
| 94 if (a + i < 5) | 94 if (a + i < 5) |
| 95 break outer; | 95 break outer; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 return sum; | 98 return sum; |
| 99 }'''; | 99 }'''; |
| 100 return check(code, disableTypeInference: false); | 100 return check(code, disableTypeInference: false, useKernelInSsa: true); |
| 101 }); | 101 }); |
| 102 } | 102 } |
| OLD | NEW |