| Index: tests/compiler/dart2js/kernel/loops_test.dart
|
| diff --git a/tests/compiler/dart2js/kernel/loops_test.dart b/tests/compiler/dart2js/kernel/loops_test.dart
|
| index 6535e95a3a66a0ddcda2d8c8672bed438c5485a3..a619c360bebf77e7c05da189e1bad412cf13cb46 100644
|
| --- a/tests/compiler/dart2js/kernel/loops_test.dart
|
| +++ b/tests/compiler/dart2js/kernel/loops_test.dart
|
| @@ -7,7 +7,7 @@ import 'package:test/test.dart';
|
| import 'helper.dart' show check;
|
|
|
| main() {
|
| - test('for-loop', () {
|
| + test('for loop', () {
|
| String code = '''
|
| main() {
|
| var a = 0;
|
| @@ -19,7 +19,7 @@ main() {
|
| return check(code);
|
| });
|
|
|
| - test('while-loop', () {
|
| + test('while loop', () {
|
| String code = '''
|
| main() {
|
| var a = 0;
|
| @@ -30,4 +30,46 @@ main() {
|
| }''';
|
| return check(code);
|
| });
|
| +
|
| + test('for-in loop', () {
|
| + String code = '''
|
| +main() {
|
| + var sum = 0;
|
| + for (var a in [1, 2, 3]) {
|
| + sum += a;
|
| + }
|
| + return sum;
|
| +}''';
|
| + // TODO(het): Check that the code is alpha-equivalent. That is,
|
| + // the same except for variable names.
|
| + return check(code);
|
| + }, skip: "The output is the same, with one variable renamed");
|
| +
|
| + test('for-in loop optimized', () {
|
| + String code = '''
|
| +main() {
|
| + var sum = 0;
|
| + for (var a in [1, 2, 3]) {
|
| + sum += a;
|
| + }
|
| + return sum;
|
| +}''';
|
| + // This is the same test as above, but by enabling type inference
|
| + // we allow the compiler to detect that it can iterate over the
|
| + // array using indexing.
|
| + return check(code, disableTypeInference: false);
|
| + });
|
| +
|
| + test('for-in loop top-level variable', () {
|
| + String code = '''
|
| +var a = 0;
|
| +main() {
|
| + var sum = 0;
|
| + for (a in [1, 2, 3]) {
|
| + sum += a;
|
| + }
|
| + return sum;
|
| +}''';
|
| + return check(code, disableTypeInference: false);
|
| + });
|
| }
|
|
|