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

Unified Diff: tests/language/function_subtype_call0_test.dart

Issue 12334070: Support runtime check of function types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor fix Created 7 years, 6 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/function_subtype_call0_test.dart
diff --git a/tests/language/function_subtype_call0_test.dart b/tests/language/function_subtype_call0_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d8626835c8474fd209ff7e9abf1dd02b6781df66
--- /dev/null
+++ b/tests/language/function_subtype_call0_test.dart
@@ -0,0 +1,42 @@
+// 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.
+// Dart test program for constructors and initializers.
+
+// Check function subtyping for classes with call functions.
+
+import 'package:expect/expect.dart';
+
+typedef void Foo(bool a, [String b]);
+typedef void Bar(bool a, [String b]);
+typedef void Baz(bool a, {String b});
+typedef void Boz(bool a);
+
+class C1 {
+ void call(bool a, [String b]) {}
+}
+
+class C2 {
+ void call(bool a, {String b}) {}
+}
+
+class C3 {
+ void call(bool a, {int b}) {}
+}
+
+main() {
+ Expect.isTrue(new C1() is Foo, 'new C1() is Foo');
+ Expect.isTrue(new C1() is Bar, 'new C1() is Bar');
+ Expect.isFalse(new C1() is Baz, 'new C1() is Baz');
+ Expect.isTrue(new C1() is Boz, 'new C1() is Boz');
+
+ Expect.isFalse(new C2() is Foo, 'new C2() is Foo');
+ Expect.isFalse(new C2() is Bar, 'new C2() is Bar');
+ Expect.isTrue(new C2() is Baz, 'new C2() is Baz');
+ Expect.isTrue(new C2() is Boz, 'new C2() is Boz');
+
+ Expect.isFalse(new C3() is Foo, 'new C3() is Foo');
+ Expect.isFalse(new C3() is Bar, 'new C3() is Bar');
+ Expect.isFalse(new C3() is Baz, 'new C3() is Baz');
+ Expect.isTrue(new C3() is Boz, 'new C3() is Boz');
+}

Powered by Google App Engine
This is Rietveld 408576698