Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, 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 // Dart test program for constructors and initializers. | |
| 5 | |
| 6 // Check that generic closures are properly instantiated. | |
| 7 | |
| 8 import 'package:expect/expect.dart'; | |
| 9 | |
| 10 typedef T F<T>(T x); | |
| 11 typedef R G<T, R>(T x); | |
| 12 | |
| 13 class C<T> { | |
| 14 get f => (T x) => x; | |
| 15 T g(T x) => x; | |
| 16 } | |
| 17 | |
| 18 main() { | |
| 19 { | |
| 20 var c = new C<int>(); | |
| 21 var f = c.f; | |
| 22 var g = c.g; | |
| 23 Expect.equals("(int) => int", f.runtimeType.toString()); //# 01: ok | |
|
Jennifer Messerly
2017/08/25 21:59:47
FYI, I filed https://github.com/dart-lang/sdk/issu
jcollins
2017/08/29 15:41:06
I slightly prefer the VM since it (at a limited gl
| |
| 24 Expect.equals("(int) => int", g.runtimeType.toString()); //# 01: ok | |
|
Jennifer Messerly
2017/08/25 21:59:47
this should be (Object) -> int
because of covaria
jcollins
2017/08/29 15:41:05
Done.
| |
| 25 Expect.equals(21, f(21)); | |
| 26 Expect.equals(14, g(14)); | |
| 27 Expect.isTrue(f is Function); | |
| 28 Expect.isTrue(g is Function); | |
| 29 Expect.isTrue(f is F); | |
| 30 Expect.isTrue(g is F); | |
| 31 Expect.isTrue(f is F<int>); | |
| 32 Expect.isTrue(g is F<int>); | |
| 33 Expect.isTrue(f is! F<bool>); | |
| 34 Expect.isTrue(g is! F<bool>); | |
| 35 Expect.isTrue(f is G<int, int>); | |
| 36 Expect.isTrue(g is G<int, int>); | |
| 37 Expect.isTrue(f is! G<int, bool>); | |
| 38 Expect.isTrue(g is! G<int, bool>); | |
|
Jennifer Messerly
2017/08/25 21:59:48
could we add these two tests, to illustrate the di
jcollins
2017/08/29 15:41:05
Done.
| |
| 39 } | |
| 40 | |
| 41 { | |
| 42 var c = new C<bool>(); | |
| 43 var f = c.f; | |
| 44 var g = c.g; | |
| 45 Expect.equals("(bool) => bool", f.runtimeType.toString()); //# 01: ok | |
| 46 Expect.equals("(bool) => bool", g.runtimeType.toString()); //# 01: ok | |
|
Jennifer Messerly
2017/08/25 21:59:48
this should be `(Object) -> bool`
jcollins
2017/08/29 15:41:05
Done.
| |
| 47 Expect.isTrue(f is F); | |
| 48 Expect.isTrue(g is F); | |
| 49 Expect.isTrue(f is! F<int>); | |
| 50 Expect.isTrue(g is! F<int>); | |
| 51 Expect.isTrue(f is F<bool>); | |
| 52 Expect.isTrue(g is F<bool>); | |
| 53 } | |
| 54 | |
| 55 { | |
| 56 var c = new C(); | |
| 57 var f = c.f; | |
| 58 var g = c.g; | |
| 59 Expect.equals("(dynamic) => dynamic", f.runtimeType.toString()); //# 01: ok | |
| 60 Expect.equals("(dynamic) => dynamic", g.runtimeType.toString()); //# 01: ok | |
|
Jennifer Messerly
2017/08/25 21:59:48
this should be `(Object) -> dynamic`
jcollins
2017/08/29 15:41:05
Done.
| |
| 61 Expect.isTrue(f is F); | |
| 62 Expect.isTrue(g is F); | |
| 63 Expect.isTrue(f is! F<int>); | |
| 64 Expect.isTrue(g is! F<int>); | |
| 65 Expect.isTrue(f is! F<bool>); | |
| 66 Expect.isTrue(g is! F<bool>); | |
| 67 } | |
| 68 } | |
| OLD | NEW |