| 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 breaks in for, do/while and while loops. | 4 // Dart test for breaks 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 BreakTest { | 8 class BreakTest { |
| 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 whileCounter++; | 33 whileCounter++; |
| 34 if (i > 3) break; | 34 if (i > 3) break; |
| 35 } | 35 } |
| 36 Expect.equals(4, whileCounter); | 36 Expect.equals(4, whileCounter); |
| 37 Expect.equals(4, i); | 37 Expect.equals(4, i); |
| 38 | 38 |
| 39 // Use a label to break to the outer loop. | 39 // Use a label to break to the outer loop. |
| 40 i = 0; | 40 i = 0; |
| 41 L: while (i < 10) { | 41 L: |
| 42 while (i < 10) { |
| 42 i++; | 43 i++; |
| 43 while (i > 5) { | 44 while (i > 5) { |
| 44 break L; | 45 break L; |
| 45 } | 46 } |
| 46 } | 47 } |
| 47 Expect.equals(6, i); | 48 Expect.equals(6, i); |
| 48 } | 49 } |
| 49 } | 50 } |
| 50 | 51 |
| 51 main() { | 52 main() { |
| 52 BreakTest.testMain(); | 53 BreakTest.testMain(); |
| 53 } | 54 } |
| OLD | NEW |