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

Unified Diff: tests/language/function_subtype1_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_subtype1_test.dart
diff --git a/tests/language/function_subtype1_test.dart b/tests/language/function_subtype1_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a7bd199e69915e34388edebab991e007c22b1ebc
--- /dev/null
+++ b/tests/language/function_subtype1_test.dart
@@ -0,0 +1,74 @@
+// 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.
+
+import 'package:expect/expect.dart';
+
+class C<T> {}
+
+typedef _();
+typedef void void_();
+typedef void void_2();
+typedef int int_();
+typedef int int_2();
+typedef Object Object_();
+typedef double double_();
+typedef void void__int(int i);
+typedef int int__int(int i);
+typedef int int__int2(int i);
+typedef int int__Object(Object o);
+typedef Object Object__int(int i);
+typedef int int__double(double d);
+typedef int int__int_int(int i1, int i2);
+typedef void inline_void_(void f());
+typedef void inline_void__int(void f(int i));
+
+main() {
+ // () -> int <: Function
+ Expect.isTrue(new C<int_>() is C<Function>);
+ // Function <: () -> int
+ Expect.isFalse(new C<Function>() is C<int_>);
+ // () -> dynamic <: () -> dynamic
+ Expect.isTrue(new C<_>() is C<_>);
+ // () -> dynamic <: () -> void
+ Expect.isTrue(new C<_>() is C<void_>);
+ // () -> void <: () -> dynamic
+ Expect.isTrue(new C<void_>() is C<_>);
+ // () -> int <: () -> void
+ Expect.isTrue(new C<int_>() is C<void_>);
+ // () -> void <: () -> int
+ Expect.isFalse(new C<void_>() is C<int_>);
+ // () -> void <: () -> void
+ Expect.isTrue(new C<void_>() is C<void_2>);
+ // () -> int <: () -> int
+ Expect.isTrue(new C<int_>() is C<int_2>);
+ // () -> int <: () -> Object
+ Expect.isTrue(new C<int_>() is C<Object_>);
+ // () -> int <: () -> double
+ Expect.isFalse(new C<int_>() is C<double_>);
+ // () -> int <: (int) -> void
+ Expect.isFalse(new C<int_>() is C<void__int>);
+ // () -> void <: (int) -> int
+ Expect.isFalse(new C<void_>() is C<int__int>);
+ // () -> void <: (int) -> void
+ Expect.isFalse(new C<void_>() is C<void__int>);
+ // (int) -> int <: (int) -> int
+ Expect.isTrue(new C<int__int>() is C<int__int2>);
+ // (Object) -> int <: (int) -> Object
+ Expect.isTrue(new C<int__Object>() is C<Object__int>);
+ // (int) -> int <: (double) -> int
+ Expect.isFalse(new C<int__int>() is C<int__double>);
+ // () -> int <: (int) -> int
+ Expect.isFalse(new C<int_>() is C<int__int>);
+ // (int) -> int <: (int,int) -> int
+ Expect.isFalse(new C<int__int>() is C<int__int_int>);
+ // (int,int) -> int <: (int) -> int
+ Expect.isFalse(new C<int__int_int>() is C<int__int>);
+ // (()->void) -> void <: ((int)->void) -> void
+ Expect.isFalse(new C<inline_void_>() is C<inline_void__int>);
+ // ((int)->void) -> void <: (()->void) -> void
+ Expect.isFalse(new C<inline_void__int>() is C<inline_void_>);
+}

Powered by Google App Engine
This is Rietveld 408576698