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 classes with call functions. |
| 7 |
| 8 import 'package:expect/expect.dart'; |
| 9 |
| 10 typedef void Foo(bool a, [String b]); |
| 11 typedef void Bar(bool a, [String b]); |
| 12 typedef void Baz(bool a, {String b}); |
| 13 typedef void Boz(bool a); |
| 14 |
| 15 class C1 { |
| 16 void call(bool a, [String b]) {} |
| 17 } |
| 18 |
| 19 class C2 { |
| 20 void call(bool a, {String b}) {} |
| 21 } |
| 22 |
| 23 class C3 { |
| 24 void call(bool a, {int b}) {} |
| 25 } |
| 26 |
| 27 main() { |
| 28 Expect.isTrue(new C1() is Foo, 'new C1() is Foo'); |
| 29 Expect.isTrue(new C1() is Bar, 'new C1() is Bar'); |
| 30 Expect.isFalse(new C1() is Baz, 'new C1() is Baz'); |
| 31 Expect.isTrue(new C1() is Boz, 'new C1() is Boz'); |
| 32 |
| 33 Expect.isFalse(new C2() is Foo, 'new C2() is Foo'); |
| 34 Expect.isFalse(new C2() is Bar, 'new C2() is Bar'); |
| 35 Expect.isTrue(new C2() is Baz, 'new C2() is Baz'); |
| 36 Expect.isTrue(new C2() is Boz, 'new C2() is Boz'); |
| 37 |
| 38 Expect.isFalse(new C3() is Foo, 'new C3() is Foo'); |
| 39 Expect.isFalse(new C3() is Bar, 'new C3() is Bar'); |
| 40 Expect.isFalse(new C3() is Baz, 'new C3() is Baz'); |
| 41 Expect.isTrue(new C3() is Boz, 'new C3() is Boz'); |
| 42 } |
OLD | NEW |