mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
b955271e51
Change-Id: I8d41ad649c83cd97253006693a0cf3676de418e9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145542 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
64 lines
2.2 KiB
Dart
64 lines
2.2 KiB
Dart
// 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.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
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 D1<S, T> extends C1<T> {}
|
|
|
|
class C2<T> {
|
|
void call(T a, {String b = ''}) {}
|
|
}
|
|
|
|
class D2<S, T> extends C2<T> {}
|
|
|
|
main() {
|
|
Function d1_String_bool = new D1<String, bool>();
|
|
Expect.isTrue(d1_String_bool is Foo, 'd1_String_bool is Foo');
|
|
Expect.isTrue(d1_String_bool is Bar, 'd1_String_bool is Bar');
|
|
Expect.isFalse(d1_String_bool is Baz, 'd1_String_bool is Baz');
|
|
Expect.isTrue(d1_String_bool is Boz, 'd1_String_bool is Boz');
|
|
|
|
Function d1_bool_int = new D1<bool, int>();
|
|
Expect.isTrue(d1_bool_int is Foo, 'd1_bool_int is Foo');
|
|
Expect.isTrue(d1_bool_int is Bar, 'd1_bool_int is Bar');
|
|
Expect.isFalse(d1_bool_int is Baz, 'd1_bool_int is Baz');
|
|
Expect.isTrue(d1_bool_int is Boz, 'd1_bool_int is Boz');
|
|
|
|
Function d1 = new D1();
|
|
Expect.isTrue(d1 is Foo, 'd1 is Foo');
|
|
Expect.isTrue(d1 is Bar, 'd1 is Bar');
|
|
Expect.isFalse(d1 is Baz, 'd1 is Baz');
|
|
Expect.isTrue(d1 is Boz, 'd1 is Boz');
|
|
|
|
Function d2_String_bool = new D2<String, bool>();
|
|
Expect.isFalse(d2_String_bool is Foo, 'd2_String_bool is Foo');
|
|
Expect.isFalse(d2_String_bool is Bar, 'd2_String_bool is Bar');
|
|
Expect.isTrue(d2_String_bool is Baz, 'd2_String_bool is Baz');
|
|
Expect.isTrue(d2_String_bool is Boz, 'd2_String_bool is Boz');
|
|
|
|
Function d2_bool_int = new D2<bool, int>();
|
|
Expect.isFalse(d2_bool_int is Foo, 'd2_bool_int is Foo');
|
|
Expect.isFalse(d2_bool_int is Bar, 'd2_bool_int is Bar');
|
|
Expect.isTrue(d2_bool_int is Baz, 'd2_bool_int is Baz');
|
|
Expect.isTrue(d2_bool_int is Boz, 'd2_bool_int is Boz');
|
|
|
|
Function d2 = new D2();
|
|
Expect.isFalse(d2 is Foo, 'd2 is Foo');
|
|
Expect.isFalse(d2 is Bar, 'd2 is Bar');
|
|
Expect.isTrue(d2 is Baz, 'd2 is Baz');
|
|
Expect.isTrue(d2 is Boz, 'd2 is Boz');
|
|
}
|