OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Test correct handling of try-catch inside try-finally. | |
6 | |
7 import "package:expect/expect.dart"; | |
8 | |
9 void main() { | |
10 print("== test1 =="); | |
11 try { | |
12 test1(); | |
13 print("Unexpected 1"); // should never go here | |
14 Expect.isTrue(false); | |
15 } catch (e) { | |
16 print("main catch 1: $e"); | |
17 Expect.equals(e, "Ball"); | |
18 } | |
Ivan Posva
2016/01/06 16:35:47
Please add some state verifying that the catch cla
Florian Schneider
2016/01/06 16:40:06
Done.
| |
19 print("== test2 =="); | |
20 try { | |
21 test2(); | |
22 print("Unexpected 2"); // should never go here | |
23 Expect.isTrue(false); | |
24 } catch (e) { | |
25 print("main catch 2: $e"); | |
26 Expect.equals(e, "Ball"); | |
27 } | |
Ivan Posva
2016/01/06 16:35:47
ditto.
Florian Schneider
2016/01/06 16:40:07
Done.
| |
28 } | |
29 | |
30 void test1() { | |
31 try { | |
32 throw "Ball"; | |
33 } finally { | |
34 try { | |
35 throw "Frisbee"; | |
36 } catch(e) { | |
37 print("test 1 catch: $e"); | |
38 Expect.equals(e, "Frisbee"); | |
39 } | |
40 } | |
41 } | |
42 | |
43 void test2() { | |
44 try { | |
45 throwError(); // call a method that throws an error | |
46 } finally { | |
47 try { | |
48 throw "Frisbee"; | |
49 } catch(e) { | |
50 print("test 2 catch: $e"); | |
51 Expect.equals(e, "Frisbee"); | |
52 } | |
53 } | |
54 } | |
55 | |
56 | |
57 void throwError() { | |
58 throw "Ball"; | |
59 } | |
OLD | NEW |