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

Side by Side Diff: tests/language/for_test.dart

Issue 459763003: dart2dart: Fix a scoping bug in the translation of loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart test program for testing for statement. 4 // Dart test program for testing for statement.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 class Helper { 8 class Helper {
9 static int f1() { 9 static int f1() {
10 for (;;) return 1; 10 for (;;) return 1;
(...skipping 27 matching lines...) Expand all
38 for (var stop = false;;) { 38 for (var stop = false;;) {
39 if (stop) { 39 if (stop) {
40 break; 40 break;
41 } else { 41 } else {
42 stop = true; 42 stop = true;
43 continue; 43 continue;
44 } 44 }
45 } 45 }
46 status = 1; 46 status = 1;
47 } 47 }
48
49 static int f6() {
50 // Verify that side effects in the condition are visible after the loop.
51 int i = 0;
52 for (; ++i < 3; ) {}
53 return i;
54 }
48 } 55 }
49 56
50 class ForTest { 57 class ForTest {
51 static testMain() { 58 static testMain() {
52 Expect.equals(1, Helper.f1()); 59 Expect.equals(1, Helper.f1());
53 Expect.equals(0, Helper.f2(-1)); 60 Expect.equals(0, Helper.f2(-1));
54 Expect.equals(0, Helper.f2(0)); 61 Expect.equals(0, Helper.f2(0));
55 Expect.equals(10, Helper.f2(10)); 62 Expect.equals(10, Helper.f2(10));
56 Expect.equals(0, Helper.f3(-1)); 63 Expect.equals(0, Helper.f3(-1));
57 Expect.equals(0, Helper.f3(0)); 64 Expect.equals(0, Helper.f3(0));
58 Expect.equals(1, Helper.f3(1)); 65 Expect.equals(1, Helper.f3(1));
59 Expect.equals(3, Helper.f3(2)); 66 Expect.equals(3, Helper.f3(2));
60 Expect.equals(6, Helper.f3(3)); 67 Expect.equals(6, Helper.f3(3));
61 Expect.equals(10, Helper.f3(4)); 68 Expect.equals(10, Helper.f3(4));
62 Expect.equals(0, Helper.f4(-1)); 69 Expect.equals(0, Helper.f4(-1));
63 Expect.equals(0, Helper.f4(0)); 70 Expect.equals(0, Helper.f4(0));
64 Expect.equals(1, Helper.f4(1)); 71 Expect.equals(1, Helper.f4(1));
65 Expect.equals(6, Helper.f4(6)); 72 Expect.equals(6, Helper.f4(6));
66 Expect.equals(6, Helper.f4(10)); 73 Expect.equals(6, Helper.f4(10));
67 74
68 Helper.f5(); 75 Helper.f5();
69 Expect.equals(1, Helper.status); 76 Expect.equals(1, Helper.status);
77
78 Expect.equals(3, Helper.f6());
70 } 79 }
71 } 80 }
72 81
73 main() { 82 main() {
74 ForTest.testMain(); 83 ForTest.testMain();
75 } 84 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/cps_ir/cps_ir_builder.dart ('k') | tests/language/while_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698