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

Unified Diff: tests/language_2/generic_function_typedef_test.dart

Issue 3008573002: Migrate test block 113 to Dart 2.0. (Closed)
Patch Set: Merge fixups Created 3 years, 4 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
« no previous file with comments | « tests/language_2/generic_function_typedef2_test.dart ('k') | tests/language_2/generic_functions_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language_2/generic_function_typedef_test.dart
diff --git a/tests/language_2/generic_function_typedef_test.dart b/tests/language_2/generic_function_typedef_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ab1bb825d9861172501306657c30cf6036d885e7
--- /dev/null
+++ b/tests/language_2/generic_function_typedef_test.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2017, 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 for a function type test that cannot be eliminated at compile time.
+
+// VMOptions=--generic-method-syntax
+
+import "package:expect/expect.dart";
+
+class A {}
+
+typedef F<S> = Function(List<S>, Function(String), num);
+typedef G<T> = Function<S>(List<S>, Function<A>(A), T);
+
+foo(List<dynamic> x, bar(String y), num z) {}
+foo2(List<int> x, bar(String y), num z) {}
+foo3<T>(List<T> x, Function<S>(S) y, num z) {}
+
+main() {
+ Expect.isTrue(foo is F);
+ Expect.isTrue(foo is F<int>);
+ Expect.isTrue(foo is F<bool>);
+
+ Expect.isFalse(foo2 is F, //# 01: ok
+ "sound function types: cannot allow passing List to List<int>"); //# 01: ok
+ Expect.isTrue(foo2 is F<int>);
+ Expect.isFalse(foo2 is F<bool>);
+
+ Expect.isFalse(foo3 is F); //# 01: ok
+ Expect.isFalse(foo3 is F<int>); //# 01: ok
+ Expect.isFalse(foo3 is F<bool>); //# 01: ok
+
+ Expect.isFalse(foo is G); //# 01: ok
+ Expect.isFalse(foo is G<int>); //# 01: ok
+ Expect.isFalse(foo is G<bool>);
+
+ Expect.isFalse(foo2 is G); //# 01: ok
+ Expect.isFalse(foo2 is G<int>); //# 01: ok
+ Expect.isFalse(foo2 is G<bool>);
+
+ Expect.isFalse(foo3 is G<Object>, //# 01: ok
+ "sound function types: cannot allow passing any Object to num"); //# 01: ok
+ Expect.isTrue(foo3 is G<int>);
+ Expect.isFalse(foo3 is G<bool>);
+}
« no previous file with comments | « tests/language_2/generic_function_typedef2_test.dart ('k') | tests/language_2/generic_functions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698