OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Dart test program for constructors and initializers. | 4 // Dart test program for constructors and initializers. |
5 | 5 |
6 // Check function subtyping for generic bound closures. | 6 // Check function subtyping for generic bound closures. |
7 | 7 |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 typedef void Foo(bool a, [String b]); | 10 typedef void Foo(bool a, [String b]); |
11 typedef void Bar(bool a, [String b]); | 11 typedef void Bar(bool a, [String b]); |
12 typedef void Baz(bool a, {String b}); | 12 typedef void Baz(bool a, {String b}); |
13 typedef int Boz(bool a); | 13 typedef int Boz(bool a); |
14 | 14 |
15 class C<T> { | 15 class C<T> { |
16 void test(String nameOfT, bool expectedResult) { | 16 void test(String nameOfT, bool expectedResult) { |
17 Expect.equals(expectedResult, (T a, [String b]) {} is Foo, | 17 Expect.equals(expectedResult, (T a, [String b]) {} is Foo, |
18 '($nameOfT,[String])->void is Foo'); | 18 '($nameOfT,[String])->void is Foo'); |
19 Expect.equals(expectedResult, (T a, [String b]) {} is Bar, | 19 Expect.equals(expectedResult, (T a, [String b]) {} is Bar, |
20 '($nameOfT,[String])->void is Bar'); | 20 '($nameOfT,[String])->void is Bar'); |
21 Expect.isFalse((T a, [String b]) {} is Baz, | 21 Expect.isFalse( |
22 '($nameOfT,[String])->void is Baz'); | 22 (T a, [String b]) {} is Baz, '($nameOfT,[String])->void is Baz'); |
23 Expect.equals(expectedResult, (T a, [String b]) {} is Boz, | 23 Expect.equals(expectedResult, (T a, [String b]) {} is Boz, |
24 '($nameOfT,[String])->void is Boz'); | 24 '($nameOfT,[String])->void is Boz'); |
25 | 25 |
26 Expect.isFalse((T a, {String b}) {} is Foo, | 26 Expect.isFalse( |
27 '($nameOfT,{b:String})->void is Foo'); | 27 (T a, {String b}) {} is Foo, '($nameOfT,{b:String})->void is Foo'); |
28 Expect.isFalse((T a, {String b}) {} is Bar, | 28 Expect.isFalse( |
29 '($nameOfT,{b:String})->void is Bar'); | 29 (T a, {String b}) {} is Bar, '($nameOfT,{b:String})->void is Bar'); |
30 Expect.equals(expectedResult, (T a, {String b}) {} is Baz, | 30 Expect.equals(expectedResult, (T a, {String b}) {} is Baz, |
31 '($nameOfT,{b:String})->void is Baz'); | 31 '($nameOfT,{b:String})->void is Baz'); |
32 Expect.equals(expectedResult, (T a, {String b}) {} is Boz, | 32 Expect.equals(expectedResult, (T a, {String b}) {} is Boz, |
33 '($nameOfT,{b:String})->void is Boz'); | 33 '($nameOfT,{b:String})->void is Boz'); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 main() { | 37 main() { |
38 new C<bool>().test('bool', true); | 38 new C<bool>().test('bool', true); |
39 new C<int>().test('int', false); | 39 new C<int>().test('int', false); |
40 new C().test('dynamic', true); | 40 new C().test('dynamic', true); |
41 } | 41 } |
OLD | NEW |