OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // Dart test program for constructors and initializers. |
| 5 |
| 6 // Check function subtyping for bound closures on generic type against generic |
| 7 // typedefs. |
| 8 |
| 9 import 'package:expect/expect.dart'; |
| 10 |
| 11 typedef int Foo<T>(T a, [String b]); |
| 12 typedef int Bar<T>(T a, [String b]); |
| 13 typedef int Baz<T>(T a, {String b}); |
| 14 typedef int Boz<T>(T a); |
| 15 typedef int Biz<T>(T a, int b); |
| 16 |
| 17 class C<T> { |
| 18 int foo(bool a, [String b]) => null; |
| 19 int baz(bool a, {String b}) => null; |
| 20 |
| 21 void test(String nameOfT, bool expectedResult) { |
| 22 Expect.equals(expectedResult, foo is Foo<T>, 'foo is Foo<$nameOfT>'); |
| 23 Expect.equals(expectedResult, foo is Bar<T>, 'foo is Bar<$nameOfT>'); |
| 24 Expect.isFalse(foo is Baz<T>, 'foo is Baz<$nameOfT>'); |
| 25 Expect.equals(expectedResult, foo is Boz<T>, 'foo is Boz<$nameOfT>'); |
| 26 Expect.isFalse(foo is Biz<T>, 'foo is Biz<$nameOfT>'); |
| 27 |
| 28 Expect.isFalse(baz is Foo<T>, 'baz is Foo<$nameOfT>'); |
| 29 Expect.isFalse(baz is Bar<T>, 'baz is Bar<$nameOfT>'); |
| 30 Expect.equals(expectedResult, baz is Baz<T>, 'baz is Baz<$nameOfT>'); |
| 31 Expect.equals(expectedResult, baz is Boz<T>, 'baz is Boz<$nameOfT>'); |
| 32 Expect.isFalse(baz is Biz<T>, 'bar is Biz<$nameOfT>'); |
| 33 } |
| 34 } |
| 35 |
| 36 main() { |
| 37 new C<bool>().test('bool', true); |
| 38 new C<int>().test('int', false); |
| 39 new C().test('dynamic', true); |
| 40 } |
OLD | NEW |