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

Unified Diff: tests/language/malformed2_test.dart

Issue 54983007: Make test of malformed types a dynamic type error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 1 month 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 | « tests/language/malformed2_lib.dart ('k') | tests/language/on_catch_malformed_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/malformed2_test.dart
diff --git a/tests/language/malformed2_test.dart b/tests/language/malformed2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cab3aba58f7ef1267f426bbc7788b73c4869fdec
--- /dev/null
+++ b/tests/language/malformed2_test.dart
@@ -0,0 +1,59 @@
+// 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.
+
+library malformed_test;
+
+// This part includes the actual tests.
+part 'malformed2_lib.dart'; /// 00: static type warning
+
+bool inCheckedMode() {
+ try {
+ var i = 42;
+ String s = i;
+ } on TypeError catch (e) {
+ return true;
+ }
+ return false;
+}
+
+bool hasFailed = false;
+
+void fail(String message) {
+ try {
+ throw message;
+ } catch (e, s) {
+ print(e);
+ print(s);
+ }
+ hasFailed = true;
+}
+
+void checkFailures() {
+ if (hasFailed) throw 'Test failed.';
+}
+
+test(bool expectTypeError, f(), [String message]) {
+ message = message != null ? ' for $message' : '';
+ try {
+ f();
+ if (expectTypeError) {
+ fail('Missing type error$message.');
+ }
+ } on TypeError catch (e) {
+ if (expectTypeError) {
+ print('Type error$message: $e');
+ } else {
+ fail('Unexpected type error$message: $e');
+ }
+ }
+}
+
+const Unresolved c1 = 0; /// 01: static type warning, compile-time error
+
+void main() {
+ print(c1); /// 01: continued
+ testValue(new List<String>()); /// 00: continued
+ testValue(null); /// 00: continued
+ checkFailures();
+}
« no previous file with comments | « tests/language/malformed2_lib.dart ('k') | tests/language/on_catch_malformed_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698