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() { |
(...skipping 15 matching lines...) Expand all Loading... | |
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 |
sra1
2017/03/21 01:43:46
//
Jacob
2017/03/21 02:25:34
Done.
| |
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 |