Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: pkg/kernel/testcases/interpreter/try_catch_finally_test.dart

Issue 3002003002: Add support for catch statements. (Closed)
Patch Set: Remove formatting changes Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 main() { 5 main() {
6 try { 6 try {
7 print('hello1'); 7 print('hello1');
8 } catch (e, _) {} finally { 8 } catch (e, _) {} finally {
9 print('hello2'); 9 print('hello2');
10 } 10 }
11 print('hello3'); 11 print('hello3');
12 print(foo()); 12 print(fReturns());
13 print(bar()); 13 print(fFinalizes());
14 print(fThrows());
14 } 15 }
15 16
16 int foo() { 17 /// Tests that the return in finally is executed.
18 int fReturns() {
17 try { 19 try {
18 print('foo 1'); 20 print('foo 1');
19 return 1; 21 return 1;
20 } catch (e, _) {} finally { 22 } catch (e, _) {} finally {
21 print('foo 2'); 23 print('foo 2');
22 return 2; 24 return 2;
23 } 25 }
24 } 26 }
25 27
26 int bar() { 28 /// Tests that finally is executed before returning.
29 int fFinalizes() {
27 try { 30 try {
28 print('bar 1'); 31 print('bar 1');
29 return 1; 32 return 1;
30 } catch (e, _) {} finally { 33 } catch (e, _) {} finally {
31 print('bar 2'); 34 print('bar 2');
32 } 35 }
33 return 0; 36 return 0;
34 } 37 }
38
39 /// Tests that the exception is caught.
40 int fThrows() {
41 try {
42 print(37);
43 throw 'Error';
44 } catch (e, _) {
45 print('Caught $e');
46 } finally {
47 print("Finalizer");
48 }
49 return 34;
50 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/interpreter/interpreter.dart ('k') | pkg/kernel/testcases/interpreter/try_catch_finally_test.dart.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698