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

Side by Side Diff: tests/compiler/dart2js/kernel/try_catch_test.dart

Issue 2570273004: Make try/catch/finally work with Kernel code and some refactoring. (Closed)
Patch Set: . Created 4 years 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
(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 import 'package:test/test.dart';
6
7 import 'helper.dart' show check;
8
9 main() {
10 test('try catch', () {
11 String code = '''
12 main() {
13 try {
14 print('hi');
15 } catch (e, s) {
16 print(e);
17 print(s);
18 print('bye');
19 }
20 }''';
21 return check(code);
22 });
23
24 test('try omit catch', () {
25 String code = '''
26 main() {
27 try {
28 print('hi');
29 } on ArgumentError {
30 print('howdy');
31 }
32 }''';
33 return check(code);
34 });
35
36 test('try finally', () {
37 String code = '''
38 main() {
39 try {
40 print('hi');
41 } finally {
42 print('bye');
43 }
44 }''';
45 return check(code);
46 });
47
48 test('try catch finally', () {
49 String code = '''
50 main() {
51 try {
52 print('hi');
53 } catch(e) {
54 print('howdy');
55 } finally {
56 print('bye');
57 }
58 }''';
59 return check(code);
60 });
61
62 test('try multi catch', () {
63 String code = '''
64 main() {
65 try {
66 print('hi');
67 } on String catch(e) {
68 print('hola');
69 } on int catch(e) {
70 print('halo');
71 } catch (e) {
72 print('howdy');
73 }
74 }''';
75 // This is the same test as above, but by enabling type inference
Siggi Cherem (dart-lang) 2016/12/15 00:59:45 delete comment? (maybe unrelated from before?)_
Emily Fortuna 2016/12/15 01:25:43 oh yeah. oops. I've been found-out for copying tes
76 // we allow the compiler to detect that it can iterate over the
77 // array using indexing.
78 return check(code, disableTypeInference: false);
Siggi Cherem (dart-lang) 2016/12/15 00:59:45 remove the disabling flag too? (below as well?)
Emily Fortuna 2016/12/15 01:25:43 Done.
79 });
80
81 test('try multi-catch finally', () {
82 String code = '''
83 main() {
84 try {
85 print('hi');
86 } on String catch(e) {
87 print('hola');
88 } on int catch(e) {
89 print('halo');
90 } catch (e) {
91 print('howdy');
92 } finally {
93 print('bye');
94 }
95 }''';
96 return check(code, disableTypeInference: false);
97 });
98 }
99
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698