OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 | 6 |
7 testSimpleBreak() { | 7 testSimpleBreak() { |
8 var x = 1; | 8 var x = 1; |
9 while (true) { | 9 while (true) { |
10 try { | 10 try { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 case 1: | 138 case 1: |
139 try { | 139 try { |
140 continue jump5; | 140 continue jump5; |
141 } finally { | 141 } finally { |
142 continue jump42; | 142 continue jump42; |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
| 147 testNestedFinally() { |
| 148 var events = ''; |
| 149 try { |
| 150 try { |
| 151 events = '$events|start'; |
| 152 } finally { |
| 153 events = '$events|start-catch'; |
| 154 } |
| 155 try { |
| 156 try { |
| 157 return; |
| 158 } finally { |
| 159 events = '$events|inner'; |
| 160 throw 0; |
| 161 } |
| 162 } finally { |
| 163 events = '$events|middle'; |
| 164 } |
| 165 } catch (e) { |
| 166 events = '$events|outer-catch'; |
| 167 } finally { |
| 168 events = '$events|outer-finally'; |
| 169 } |
| 170 Expect.equals( |
| 171 events, |
| 172 '|start|start-catch|inner|middle|outer-catch|outer-finally'); |
| 173 } |
| 174 |
147 main() { | 175 main() { |
148 Expect.isTrue(testSimpleBreak() == 3); | 176 Expect.isTrue(testSimpleBreak() == 3); |
149 Expect.isTrue(testReturnFinally() == 42); | 177 Expect.isTrue(testReturnFinally() == 42); |
150 Expect.isTrue(testNestedReturnFinally() == 42); | 178 Expect.isTrue(testNestedReturnFinally() == 42); |
151 Expect.isTrue(testReturnInsideLoop() == 42); | 179 Expect.isTrue(testReturnInsideLoop() == 42); |
152 Expect.isTrue(testStopContinueInsideLoop() == 42); | 180 Expect.isTrue(testStopContinueInsideLoop() == 42); |
153 Expect.isTrue(testStopBreakInsideLoop() == 42); | 181 Expect.isTrue(testStopBreakInsideLoop() == 42); |
154 Expect.isTrue(testStopBreakInsideLoop2() == 42); | 182 Expect.isTrue(testStopBreakInsideLoop2() == 42); |
155 Expect.isTrue(testStopContinueInsideLoop() == 42); | 183 Expect.isTrue(testStopContinueInsideLoop() == 42); |
156 Expect.isTrue(testStopContinueInsideSwitch() == 42); | 184 Expect.isTrue(testStopContinueInsideSwitch() == 42); |
157 Expect.isTrue(testStopContinueInsideSwitch2() == 42); | 185 Expect.isTrue(testStopContinueInsideSwitch2() == 42); |
| 186 testNestedFinally(); |
158 } | 187 } |
OLD | NEW |