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

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: 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() {
sigurdm 2014/08/12 07:26:37 Maybe a comment explaining what we are testing?
Kevin Millikin (Google) 2014/08/12 08:54:55 Good idea, done.
50 int i = 0;
51 for (; ++i < 3; ) {}
52 return i;
53 }
48 } 54 }
49 55
50 class ForTest { 56 class ForTest {
51 static testMain() { 57 static testMain() {
52 Expect.equals(1, Helper.f1()); 58 Expect.equals(1, Helper.f1());
53 Expect.equals(0, Helper.f2(-1)); 59 Expect.equals(0, Helper.f2(-1));
54 Expect.equals(0, Helper.f2(0)); 60 Expect.equals(0, Helper.f2(0));
55 Expect.equals(10, Helper.f2(10)); 61 Expect.equals(10, Helper.f2(10));
56 Expect.equals(0, Helper.f3(-1)); 62 Expect.equals(0, Helper.f3(-1));
57 Expect.equals(0, Helper.f3(0)); 63 Expect.equals(0, Helper.f3(0));
58 Expect.equals(1, Helper.f3(1)); 64 Expect.equals(1, Helper.f3(1));
59 Expect.equals(3, Helper.f3(2)); 65 Expect.equals(3, Helper.f3(2));
60 Expect.equals(6, Helper.f3(3)); 66 Expect.equals(6, Helper.f3(3));
61 Expect.equals(10, Helper.f3(4)); 67 Expect.equals(10, Helper.f3(4));
62 Expect.equals(0, Helper.f4(-1)); 68 Expect.equals(0, Helper.f4(-1));
63 Expect.equals(0, Helper.f4(0)); 69 Expect.equals(0, Helper.f4(0));
64 Expect.equals(1, Helper.f4(1)); 70 Expect.equals(1, Helper.f4(1));
65 Expect.equals(6, Helper.f4(6)); 71 Expect.equals(6, Helper.f4(6));
66 Expect.equals(6, Helper.f4(10)); 72 Expect.equals(6, Helper.f4(10));
67 73
68 Helper.f5(); 74 Helper.f5();
69 Expect.equals(1, Helper.status); 75 Expect.equals(1, Helper.status);
76
77 Expect.equals(3, Helper.f6());
70 } 78 }
71 } 79 }
72 80
73 main() { 81 main() {
74 ForTest.testMain(); 82 ForTest.testMain();
75 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698