OLD | NEW |
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 for continue in for, do/while and while loops. | 4 // Dart test for continue in for, do/while and while loops. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class ContinueTest { | 8 class ContinueTest { |
9 static testMain() { | 9 static testMain() { |
10 int i; | 10 int i; |
(...skipping 20 matching lines...) Expand all Loading... |
31 while (i < 10) { | 31 while (i < 10) { |
32 i++; | 32 i++; |
33 if (i > 3) continue; | 33 if (i > 3) continue; |
34 whileCounter++; | 34 whileCounter++; |
35 } | 35 } |
36 Expect.equals(3, whileCounter); | 36 Expect.equals(3, whileCounter); |
37 Expect.equals(10, i); | 37 Expect.equals(10, i); |
38 | 38 |
39 // Use a label to continue to the outer loop. | 39 // Use a label to continue to the outer loop. |
40 i = 0; | 40 i = 0; |
41 L: while (i < 50) { | 41 L: |
| 42 while (i < 50) { |
42 i += 3; | 43 i += 3; |
43 while (i < 30) { | 44 while (i < 30) { |
44 i += 2; | 45 i += 2; |
45 if (i < 10) { | 46 if (i < 10) { |
46 continue L; | 47 continue L; |
47 } else { | 48 } else { |
48 i++; | 49 i++; |
49 break; | 50 break; |
50 } | 51 } |
51 } | 52 } |
(...skipping 14 matching lines...) Expand all Loading... |
66 } | 67 } |
67 i = 30; | 68 i = 30; |
68 } while (false); | 69 } while (false); |
69 Expect.equals(22, i); | 70 Expect.equals(22, i); |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 main() { | 74 main() { |
74 ContinueTest.testMain(); | 75 ContinueTest.testMain(); |
75 } | 76 } |
OLD | NEW |