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

Unified Diff: tests/language/on_catch_malformed_type_test.dart

Issue 12220011: Handle malformed types in catch-on. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: New implementation + test. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: tests/language/on_catch_malformed_type_test.dart
diff --git a/tests/language/on_catch_malformed_type_test.dart b/tests/language/on_catch_malformed_type_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b6a93add1b98152f17d55ad01ebc29b1cf712607
--- /dev/null
+++ b/tests/language/on_catch_malformed_type_test.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2013, 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.
+
+// Check that malformed types in on-catch are handled correct, that is
ngeoffray 2013/02/18 15:48:35 correct -> correctly
Johnni Winther 2013/02/19 07:08:54 Done.
+// catches all in production mode and throws a type error in checked mode.
+
+isCheckedMode() {
+ try {
+ var i = 1;
+ String s = i;
ngeoffray 2013/02/18 15:48:35 How about String s = 1 ?
Johnni Winther 2013/02/19 07:08:54 Done.
+ return false;
+ } on TypeError catch(e) {
+ return true;
+ }
+}
+
+checkTypeError(f()) {
+ if(isCheckedMode()) {
+ try {
+ f();
+ Expect.fail("Type error expected in checking mode");
+ } on TypeError catch(ok) {
+ }
+ } else {
+ f();
+ }
+}
+
+catchUnresolvedBefore() {
+ try {
+ throw "foo";
+ Expect.fail("This code shouldn't be executed");
+ } on String catch(oks) {
+ // This is tested before the catch block below.
+ } on Unavailable catch(ex) {
+ Expect.fail("This code shouldn't be executed");
+ }
+}
+
+catchUnresolvedAfter() {
+ try {
+ throw "foo";
+ Expect.fail("This code shouldn't be executed");
+ } on Unavailable catch(ex) {
+ // This is tested before the catch block below.
+ // In production mode the test is always true, in checked mode
+ // it throws a type error.
+ } on String catch(oks) {
+ Expect.fail("This code shouldn't be executed");
+ }
+}
+
+main() {
+ catchUnresolvedBefore();
+ checkTypeError(catchUnresolvedAfter);
+}
« tests/language/language_dart2js.status ('K') | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698