OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // Dart test program for testing execution of finally blocks on | |
5 // control flow breaks because of 'return', 'continue' etc. | |
6 | |
7 | |
8 class Helper { | |
9 Helper() : i = 0 { } | |
10 | |
11 int f1() { | |
12 try { | |
13 int j; | |
14 j = func(); | |
15 i = 1; | |
16 } finally { | |
17 i = i + 10; | |
18 } | |
19 return i + 200; // Should return here with i = 211. | |
20 try { | |
21 int j; | |
22 j = func(); | |
23 } finally { | |
24 i = i + 10; // Should not get executed as part of return above. | |
25 } | |
26 } | |
27 | |
28 static int func() { | |
29 int i = 0; | |
30 while (i < 10) { | |
31 i++; | |
32 } | |
33 return i; | |
34 } | |
35 | |
36 int i; | |
37 } | |
38 | |
39 class ExecuteFinally4Test { | |
40 static testMain() { | |
41 Helper obj = new Helper(); | |
42 Expect.equals(211, obj.f1()); | |
43 Expect.equals(11, obj.i); | |
44 } | |
45 } | |
46 | |
47 main() { | |
48 ExecuteFinally4Test.testMain(); | |
49 } | |
OLD | NEW |