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 top level functions. |
| 7 |
| 8 import 'package:expect/expect.dart'; |
| 9 |
| 10 typedef int Foo<T>(T a, [String b]); |
| 11 typedef int Bar<T>(T a, [String b]); |
| 12 typedef int Baz<T>(T a, {String b}); |
| 13 typedef int Boz<T>(T a); |
| 14 |
| 15 int foo(bool a, [String b]) => null; |
| 16 int baz(bool a, {String b}) => null; |
| 17 int boz(bool a, {int b}) => null; |
| 18 |
| 19 class C<T> { |
| 20 void test(String nameOfT, bool expectedResult) { |
| 21 Expect.equals(expectedResult, foo is Foo<T>, 'foo is Foo<$nameOfT>'); |
| 22 Expect.equals(expectedResult, foo is Bar<T>, 'foo is Bar<$nameOfT>'); |
| 23 Expect.isFalse(foo is Baz<T>, 'foo is Baz<$nameOfT>'); |
| 24 Expect.equals(expectedResult, foo is Boz<T>, 'foo is Boz<$nameOfT>'); |
| 25 |
| 26 Expect.isFalse(baz is Foo<T>, 'foo is Foo<$nameOfT>'); |
| 27 Expect.isFalse(baz is Bar<T>, 'foo is Bar<$nameOfT>'); |
| 28 Expect.equals(expectedResult, baz is Baz<T>, 'foo is Baz<$nameOfT>'); |
| 29 Expect.equals(expectedResult, baz is Boz<T>, 'foo is Boz<$nameOfT>'); |
| 30 |
| 31 Expect.isFalse(boz is Foo<T>, 'foo is Foo<$nameOfT>'); |
| 32 Expect.isFalse(boz is Bar<T>, 'foo is Bar<$nameOfT>'); |
| 33 Expect.isFalse(boz is Baz<T>, 'foo is Baz<$nameOfT>'); |
| 34 Expect.equals(expectedResult, boz is Boz<T>, 'foo is Boz<$nameOfT>'); |
| 35 } |
| 36 } |
| 37 |
| 38 main() { |
| 39 new C<bool>().test('bool', true); |
| 40 new C<int>().test('int', false); |
| 41 new C().test('dynamic', true); |
| 42 } |
OLD | NEW |