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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/kernel/try_catch_test.dart
diff --git a/tests/compiler/dart2js/kernel/try_catch_test.dart b/tests/compiler/dart2js/kernel/try_catch_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..972667c7b6c53845166c0eac9a58c0b79731caba
--- /dev/null
+++ b/tests/compiler/dart2js/kernel/try_catch_test.dart
@@ -0,0 +1,96 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test/test.dart';
+
+import 'helper.dart' show check;
+
+main() {
+ test('try catch', () {
+ String code = '''
+main() {
+ try {
+ print('hi');
+ } catch (e, s) {
+ print(e);
+ print(s);
+ print('bye');
+ }
+}''';
+ return check(code);
+ });
+
+ test('try omit catch', () {
+ String code = '''
+main() {
+ try {
+ print('hi');
+ } on ArgumentError {
+ print('howdy');
+ }
+}''';
+ return check(code);
+ });
+
+ test('try finally', () {
+ String code = '''
+main() {
+ try {
+ print('hi');
+ } finally {
+ print('bye');
+ }
+}''';
+ return check(code);
+ });
+
+ test('try catch finally', () {
+ String code = '''
+main() {
+ try {
+ print('hi');
+ } catch(e) {
+ print('howdy');
+ } finally {
+ print('bye');
+ }
+}''';
+ return check(code);
+ });
+
+ test('try multi catch', () {
+ String code = '''
+main() {
+ try {
+ print('hi');
+ } on String catch(e) {
+ print('hola');
+ } on int catch(e) {
+ print('halo');
+ } catch (e) {
+ print('howdy');
+ }
+}''';
+ return check(code);
+ });
+
+ test('try multi-catch finally', () {
+ String code = '''
+main() {
+ try {
+ print('hi');
+ } on String catch(e) {
+ print('hola');
+ } on int catch(e) {
+ print('halo');
+ } catch (e) {
+ print('howdy');
+ } finally {
+ print('bye');
+ }
+}''';
+ return check(code);
+ });
+}
+
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698