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

Side by Side Diff: tests/language_strong/generic_methods_generic_class_tearoff_test.dart

Issue 2737933002: Add tests for generic methods in strong mode (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library generic_methods_generic_class_tearoff_test;
6
7 import "package:expect/expect.dart";
8
9 class A<T> {
10 T fun(T t) => t;
11 }
12
13 typedef Int2Int = int Function(int);
14 typedef String2String = String Function(String);
15 typedef Object2Object = Object Function(Object);
16 typedef GenericMethod = T Function<T>(T);
17
18 main() {
19 A<int> x = new A<int>();
20 var f = x.fun;
21 A<String> y = new A<String>();
22 var g = y.fun;
23 A z = new A();
eernst 2017/03/09 14:55:02 This one depends on instantiate-to-bound for a raw
Dmitry Stefantsov 2017/03/10 13:21:53 Thank you! Done.
24 var h = z.fun;
25
26 Expect.isTrue(f is Int2Int);
27 Expect.isTrue(f is! String2String);
28 Expect.isTrue(f is! Object2Object);
Leaf 2017/03/09 05:51:19 I think this one should be true. The reified type
karlklose 2017/03/09 09:17:00 Why is it not `int -> int`?
karlklose 2017/03/09 09:18:53 Or do you mean that 'int -> int' is a subtype of '
floitsch 2017/03/09 11:27:17 Because of covariant generics. We have to support:
Leaf 2017/03/09 19:17:26 Is the writeup of that ready to share yet?
eernst 2017/03/10 13:13:51 We did that already: https://github.com/dart-lang/
Dmitry Stefantsov 2017/03/10 13:21:53 Thank you! That explains a lot.
29 Expect.isTrue(f is! GenericMethod);
30
31 Expect.isTrue(g is! Int2Int);
32 Expect.isTrue(g is String2String);
33 Expect.isTrue(g is! Object2Object);
Leaf 2017/03/09 05:51:18 As above.
Dmitry Stefantsov 2017/03/10 13:21:53 Done.
34 Expect.isTrue(g is! GenericMethod);
35
36 Expect.isTrue(h is! Int2Int);
37 Expect.isTrue(h is! String2String);
38 Expect.isTrue(h is Object2Object);
39 Expect.isTrue(h is! GenericMethod);
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698