OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // Dart test for function type alias with a type parameter as result type. | 5 // Dart test for function type alias with a type parameter as result type. |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 typedef bool F<bool>(bool a); // 'bool' is not the boolean type. | 9 typedef bool F<bool>(bool a); // 'bool' is not the boolean type. |
10 | 10 |
11 bool bar(bool a) { | 11 bool bar(bool a) {} |
12 } | |
13 | 12 |
14 int baz(int a) { | 13 int baz(int a) {} |
15 } | |
16 | 14 |
17 class A<T> { | 15 class A<T> { |
18 T foo(T a) { | 16 T foo(T a) {} |
19 } | |
20 } | 17 } |
21 | 18 |
22 main() { | 19 main() { |
23 Expect.isTrue(bar is F); | 20 Expect.isTrue(bar is F); |
24 Expect.isTrue(baz is F); | 21 Expect.isTrue(baz is F); |
25 Expect.isTrue(bar is F<bool>); | 22 Expect.isTrue(bar is F<bool>); |
26 Expect.isTrue(baz is F<int>); | 23 Expect.isTrue(baz is F<int>); |
27 Expect.isTrue(bar is !F<int>); | 24 Expect.isTrue(bar is! F<int>); |
28 Expect.isTrue(baz is !F<bool>); | 25 Expect.isTrue(baz is! F<bool>); |
29 | 26 |
30 var b = new A<bool>(); | 27 var b = new A<bool>(); |
31 var i = new A<int>(); | 28 var i = new A<int>(); |
32 Expect.isTrue(b.foo is F); | 29 Expect.isTrue(b.foo is F); |
33 Expect.isTrue(i.foo is F); | 30 Expect.isTrue(i.foo is F); |
34 Expect.isTrue(b.foo is F<bool>); | 31 Expect.isTrue(b.foo is F<bool>); |
35 Expect.isTrue(i.foo is F<int>); | 32 Expect.isTrue(i.foo is F<int>); |
36 Expect.isTrue(b.foo is !F<int>); | 33 Expect.isTrue(b.foo is! F<int>); |
37 Expect.isTrue(i.foo is !F<bool>); | 34 Expect.isTrue(i.foo is! F<bool>); |
38 } | 35 } |
OLD | NEW |