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 try { | |
16 i = 1; | |
17 return i; // Value of i is 1 on return. | |
18 } finally { | |
19 i = i + 400; // Should get executed when we return. | |
20 } | |
21 i = 2; // Should not get executed. | |
22 return i; | |
23 } finally { | |
24 i = i + 800; // Should get executed when we return. | |
25 } | |
26 return i + 200; // Should not get executed. | |
27 } | |
28 | |
29 static int func() { | |
30 int i = 0; | |
31 while (i < 10) { | |
32 i++; | |
33 } | |
34 return i; | |
35 } | |
36 | |
37 int i; | |
38 } | |
39 | |
40 class ExecuteFinally2Test { | |
41 static testMain() { | |
42 Helper obj = new Helper(); | |
43 Expect.equals(1, obj.f1()); | |
44 Expect.equals(1201, obj.i); | |
45 } | |
46 } | |
47 | |
48 main() { | |
49 ExecuteFinally2Test.testMain(); | |
50 } | |
OLD | NEW |