Chromium Code Reviews| Index: tests/language/function_subtype_call1_test.dart |
| diff --git a/tests/language/function_subtype_call1_test.dart b/tests/language/function_subtype_call1_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ebeb81bd878cc9c345e116e255c57ad9434775e5 |
| --- /dev/null |
| +++ b/tests/language/function_subtype_call1_test.dart |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| +// Dart test program for constructors and initializers. |
| + |
| +// Check function subtyping for classes with call functions. |
| + |
| +typedef void Foo(bool a, [String b]); |
| +typedef void Bar(bool a, [String b]); |
| +typedef void Baz(bool a, {String b}); |
| +typedef void Boz(bool a); |
| + |
| +class C1<T> { |
| + void call(T a, [String b]) {} |
| +} |
| + |
| +class C2<T> { |
| + void call(T a, {String b}) {} |
| +} |
| + |
| +main() { |
| + // TODO(johnniwinther): The use of [runtimeType] is inserted to ensure the |
| + // generation of runtime type information. Remove when this is computed |
| + // on the basis of the checks. |
| + //print(new C1<bool>().runtimeType); |
|
karlklose
2013/03/13 10:33:34
Debug code.
Johnni Winther
2013/03/22 07:30:24
Removed.
|
| + |
| + Expect.isTrue(new C1<bool>() is Foo, 'new C1<bool>() is Foo'); |
| + Expect.isTrue(new C1<bool>() is Bar, 'new C1<bool>() is Bar'); |
| + Expect.isFalse(new C1<bool>() is Baz, 'new C1<bool>() is Baz'); |
| + Expect.isTrue(new C1<bool>() is Boz, 'new C1<bool>() is Boz'); |
| + |
| + Expect.isFalse(new C1<int>() is Foo, 'new C1<int>() is Foo'); |
| + Expect.isFalse(new C1<int>() is Bar, 'new C1<int>() is Bar'); |
| + Expect.isFalse(new C1<int>() is Baz, 'new C1<int>() is Baz'); |
| + Expect.isFalse(new C1<int>() is Boz, 'new C1<int>() is Boz'); |
| + |
| + Expect.isTrue(new C1() is Foo, 'new C1() is Foo'); |
| + Expect.isTrue(new C1() is Bar, 'new C1() is Bar'); |
| + Expect.isFalse(new C1() is Baz, 'new C1() is Baz'); |
| + Expect.isTrue(new C1() is Boz, 'new C1() is Boz'); |
| + |
| + Expect.isFalse(new C2<bool>() is Foo, 'new C2<bool>() is Foo'); |
| + Expect.isFalse(new C2<bool>() is Bar, 'new C2<bool>() is Bar'); |
| + Expect.isTrue(new C2<bool>() is Baz, 'new C2<bool>() is Baz'); |
| + Expect.isTrue(new C2<bool>() is Boz, 'new C2<bool>() is Boz'); |
| + |
| + Expect.isFalse(new C2<int>() is Foo, 'new C2<int>() is Foo'); |
| + Expect.isFalse(new C2<int>() is Bar, 'new C2<int>() is Bar'); |
| + Expect.isFalse(new C2<int>() is Baz, 'new C2<int>() is Baz'); |
| + Expect.isFalse(new C2<int>() is Boz, 'new C2<int>() is Boz'); |
| + |
| + Expect.isFalse(new C2() is Foo, 'new C2() is Foo'); |
| + Expect.isFalse(new C2() is Bar, 'new C2() is Bar'); |
| + Expect.isTrue(new C2() is Baz, 'new C2() is Baz'); |
| + Expect.isTrue(new C2() is Boz, 'new C2() is Boz'); |
| +} |