| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 test('for-in loop', () { | 46 test('for-in loop', () { |
| 47 String code = ''' | 47 String code = ''' |
| 48 main() { | 48 main() { |
| 49 var sum = 0; | 49 var sum = 0; |
| 50 for (var a in [1, 2, 3]) { | 50 for (var a in [1, 2, 3]) { |
| 51 sum += a; | 51 sum += a; |
| 52 } | 52 } |
| 53 return sum; | 53 return sum; |
| 54 }'''; | 54 }'''; |
| 55 // TODO(het): Check that the code is alpha-equivalent. That is, | |
| 56 // the same except for variable names. | |
| 57 return check(code); | 55 return check(code); |
| 58 }, skip: "The output is the same, with one variable renamed"); | 56 }); |
| 59 | 57 |
| 60 test('for-in loop optimized', () { | 58 test('for-in loop optimized', () { |
| 61 String code = ''' | 59 String code = ''' |
| 62 main() { | 60 main() { |
| 63 var sum = 0; | 61 var sum = 0; |
| 64 for (var a in [1, 2, 3]) { | 62 for (var a in [1, 2, 3]) { |
| 65 sum += a; | 63 sum += a; |
| 66 } | 64 } |
| 67 return sum; | 65 return sum; |
| 68 }'''; | 66 }'''; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 95 sum += a; | 93 sum += a; |
| 96 if (a + i < 5) | 94 if (a + i < 5) |
| 97 break outer; | 95 break outer; |
| 98 } | 96 } |
| 99 } | 97 } |
| 100 return sum; | 98 return sum; |
| 101 }'''; | 99 }'''; |
| 102 return check(code, disableTypeInference: false); | 100 return check(code, disableTypeInference: false); |
| 103 }); | 101 }); |
| 104 } | 102 } |
| OLD | NEW |