| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // A break label must be declared where it's used. | 5 // A break label must be declared where it's used. |
| 6 undeclaredBreakLabel1() { | 6 undeclaredBreakLabel1() { |
| 7 foo: { break bar; break foo; } /// 01: compile-time error | 7 foo: { break bar; break foo; } // /// 01: compile-time error |
| 8 } | 8 } |
| 9 | 9 |
| 10 undeclaredBreakLabel2() { | 10 undeclaredBreakLabel2() { |
| 11 foo: while (true) { break bar; break foo; } /// 02: compile-time error | 11 foo: while (true) { break bar; break foo; } // /// 02: compile-time error |
| 12 } | 12 } |
| 13 | 13 |
| 14 // An unlabeled break must be inside a loop or switch. | 14 // An unlabeled break must be inside a loop or switch. |
| 15 noBreakTarget() { | 15 noBreakTarget() { |
| 16 foo: if (true) { break; break foo; } /// 03: compile-time error | 16 foo: if (true) { break; break foo; } // /// 03: compile-time error |
| 17 } | 17 } |
| 18 | 18 |
| 19 // A continue label must be declared where it's used. | 19 // A continue label must be declared where it's used. |
| 20 undeclaredContinueLabel() { | 20 undeclaredContinueLabel() { |
| 21 foo: for (;;) { continue bar; break foo; } /// 04: compile-time error | 21 foo: for (;;) { continue bar; break foo; } // /// 04: compile-time error |
| 22 } | 22 } |
| 23 | 23 |
| 24 // An unlabeled continue must be inside a loop. | 24 // An unlabeled continue must be inside a loop. |
| 25 noContinueTarget() { | 25 noContinueTarget() { |
| 26 foo: if (true) continue; else break foo; /// 05: compile-time error | 26 foo: if (true) continue; else break foo; // /// 05: compile-time error |
| 27 } | 27 } |
| 28 | 28 |
| 29 // A continue label must point to a continue-able statement. | 29 // A continue label must point to a continue-able statement. |
| 30 wrongContinueLabel() { | 30 wrongContinueLabel() { |
| 31 foo: if (true) continue foo; /// 06: compile-time error | 31 foo: if (true) continue foo; // /// 06: compile-time error |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Labels are not captured by closures. | 34 // Labels are not captured by closures. |
| 35 noncaptureLabel() { | 35 noncaptureLabel() { |
| 36 foo: { /// 07: compile-time error | 36 foo: { // /// 07: compile-time error |
| 37 (() { break foo; })(); /// 07: continued | 37 (() { break foo; })(); // /// 07: continued |
| 38 break foo; /// 07: continued | 38 break foo; // /// 07: continued |
| 39 } /// 07: continued | 39 } // /// 07: continued |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Implicit break targets are not captured by closures. | 42 // Implicit break targets are not captured by closures. |
| 43 noncaptureBreak() { | 43 noncaptureBreak() { |
| 44 while(true) (() { break; })(); /// 08: compile-time error | 44 while(true) (() { break; })(); // /// 08: compile-time error |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Implicit continue targets are not captured by closures. | 47 // Implicit continue targets are not captured by closures. |
| 48 noncaptureContinue() { | 48 noncaptureContinue() { |
| 49 while(true) (() { continue; })(); /// 09: compile-time error | 49 while(true) (() { continue; })(); // /// 09: compile-time error |
| 50 } | 50 } |
| 51 | 51 |
| 52 main() { | 52 main() { |
| 53 undeclaredBreakLabel1(); | 53 undeclaredBreakLabel1(); |
| 54 undeclaredBreakLabel2(); | 54 undeclaredBreakLabel2(); |
| 55 noBreakTarget(); | 55 noBreakTarget(); |
| 56 undeclaredContinueLabel(); | 56 undeclaredContinueLabel(); |
| 57 noContinueTarget(); | 57 noContinueTarget(); |
| 58 wrongContinueLabel(); | 58 wrongContinueLabel(); |
| 59 noncaptureLabel(); | 59 noncaptureLabel(); |
| 60 noncaptureBreak(); | 60 noncaptureBreak(); |
| 61 noncaptureContinue(); | 61 noncaptureContinue(); |
| 62 } | 62 } |
| OLD | NEW |