Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: tests/compiler/dart2js/kernel/loops_test.dart

Issue 2667003005: Use for-in loop variable name if possible (Closed)
Patch Set: also non-indexed loops Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698