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

Unified Diff: pkg/kernel/testcases/reify/generic_methods_unused_parameter_test.dart

Issue 2756693002: Add generic-methods 'golden' tests for 'reify' transformation (Closed)
Patch Set: Mark tests with Crash/Fail in reify.status instead of excluding Created 3 years, 9 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 | « pkg/kernel/testcases/reify/generic_methods_tearoff_specialization_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/testcases/reify/generic_methods_unused_parameter_test.dart
diff --git a/pkg/kernel/testcases/reify/generic_methods_unused_parameter_test.dart b/pkg/kernel/testcases/reify/generic_methods_unused_parameter_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3c52eea6d49879bed28567ab9f7672615fb674f2
--- /dev/null
+++ b/pkg/kernel/testcases/reify/generic_methods_unused_parameter_test.dart
@@ -0,0 +1,89 @@
+// 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.
+
+// Test that generic methods with unused parameters aren't treated as
+// non-generic methods, but can be specialized as such.
+
+library generic_methods_unused_parameter_test;
+
+import "test_base.dart";
+
+typedef Fun = int Function();
+typedef FunReq = int Function(int);
+typedef FunOpt = int Function([int]);
+typedef FunReqOpt = int Function(int, [int]);
+typedef FunNam = int Function({int p});
+typedef FunReqNam = int Function(int, {int p});
+
+typedef FunTyp = int Function<T>();
+typedef FunTypReq = int Function<T>(int);
+typedef FunTypOpt = int Function<T>([int]);
+typedef FunTypReqOpt = int Function<T>(int, [int]);
+typedef FunTypNam = int Function<T>({int p});
+typedef FunTypReqNam = int Function<T>(int, {int p});
+
+int fun() {}
+int funReq(int x) => x;
+int funOpt([int y]) => y ?? 42;
+int funReqOpt(int x, [int y]) => x;
+int funNam({int p}) => p ?? 42;
+int funReqNam(int x, {int p}) => x;
+
+int funTyp<T>() {}
+int funTypReq<T>(int x) => x;
+int funTypOpt<T>([int y]) => y ?? 42;
+int funTypReqOpt<T>(int x, [int y]) => x;
+int funTypNam<T>({int p}) => p ?? 42;
+int funTypReqNam<T>(int x, {int p}) => x;
+
+main() {
+ Fun varFun = funTyp;
+ FunReq varFunReq = funTypReq;
+ FunOpt varFunOpt = funTypOpt;
+ FunReqOpt varFunReqOpt = funTypReqOpt;
+ FunNam varFunNam = funTypNam;
+ FunReqNam varFunReqNam = funTypReqNam;
+
+ expectTrue(fun is Fun);
+ expectTrue(fun is! FunTyp);
+ expectTrue(funTyp is! Fun);
+ expectTrue(funTyp is FunTyp);
+ expectTrue(varFun is Fun);
+ expectTrue(varFun is! FunTyp);
+
+ expectTrue(funReq is FunReq);
+ expectTrue(funReq is! FunTypReq);
+ expectTrue(funTypReq is! FunReq);
+ expectTrue(funTypReq is FunTypReq);
+ expectTrue(varFunReq is FunReq);
+ expectTrue(varFunReq is! FunTypReq);
+
+ expectTrue(funOpt is FunOpt);
+ expectTrue(funOpt is! FunTypOpt);
+ expectTrue(funTypOpt is! FunOpt);
+ expectTrue(funTypOpt is FunTypOpt);
+ expectTrue(varFunOpt is FunOpt);
+ expectTrue(varFunOpt is! FunTypOpt);
+
+ expectTrue(funReqOpt is FunReqOpt);
+ expectTrue(funReqOpt is! FunTypReqOpt);
+ expectTrue(funTypReqOpt is! FunReqOpt);
+ expectTrue(funTypReqOpt is FunTypReqOpt);
+ expectTrue(varFunReqOpt is FunReqOpt);
+ expectTrue(varFunReqOpt is! FunTypReqOpt);
+
+ expectTrue(funNam is FunNam);
+ expectTrue(funNam is! FunTypNam);
+ expectTrue(funTypNam is! FunNam);
+ expectTrue(funTypNam is FunTypNam);
+ expectTrue(varFunNam is FunNam);
+ expectTrue(varFunNam is! FunTypNam);
+
+ expectTrue(funReqNam is FunReqNam);
+ expectTrue(funReqNam is! FunTypReqNam);
+ expectTrue(funTypReqNam is! FunReqNam);
+ expectTrue(funTypReqNam is FunTypReqNam);
+ expectTrue(varFunReqNam is FunReqNam);
+ expectTrue(varFunReqNam is! FunTypReqNam);
+}
« no previous file with comments | « pkg/kernel/testcases/reify/generic_methods_tearoff_specialization_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698