dart-sdk/tests/language_2/function_subtype2_test.dart
William Hesse b3e7f6d299 Recommit "migrate function type tests""
This reverts commit ba09eb787c, which was
a revert of ca6bec3414.
New status lines have been added to tests/languge_2/language_2_dart.js.status.

Bug:
Change-Id: I9e5b344d67df1fb00d5a51078a3d2b6113223a3e
Reviewed-on: https://dart-review.googlesource.com/7800
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2017-09-22 17:52:27 +00:00

141 lines
6.8 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 optional parameters.
import 'package:expect/expect.dart';
typedef void T1(int a, int b);
typedef void T2(int a, [int b]);
typedef void T3([int a, int b]);
typedef void T4(int a, [int b, int c]);
typedef void T5([int a, int b, int c]);
class C<T, S, U> {
get m1 => (T a, S b) {};
get m2 => (T a, [S b]) {};
get m3 => ([T a, S b]) {};
get m4 => (T a, [S b, U c]) {};
get m5 => ([T a, S b, U c]) {};
}
main() {
var c1 = new C<int, int, int>();
Expect.isTrue(c1.m1 is T1, "(int,int)->void is (int,int)->void");
Expect.isFalse(c1.m1 is T2, "(int,int)->void is not (int,[int])->void");
Expect.isFalse(c1.m1 is T3, "(int,int)->void is not ([int,int])->void");
Expect.isFalse(c1.m1 is T4, "(int,int)->void is not (int,[int,int])->void");
Expect.isFalse(c1.m1 is T5, "(int,int)->void is not ([int,int,int])->void");
Expect.isTrue(c1.m2 is T1, "(int,[int])->void is (int,int)->void");
Expect.isTrue(c1.m2 is T2, "(int,[int])->void is (int,[int])->void");
Expect.isFalse(c1.m2 is T3, "(int,[int])->void is not ([int,int])->void");
Expect.isFalse(c1.m2 is T4, "(int,[int])->void is not (int,[int,int])->void");
Expect.isFalse(c1.m2 is T5, "(int,[int])->void is not ([int,int,int])->void");
Expect.isTrue(c1.m3 is T1, "([int,int])->void is (int,int)->void");
Expect.isTrue(c1.m3 is T2, "([int,int])->void is (int,[int])->void");
Expect.isTrue(c1.m3 is T3, "([int,int])->void is ([int,int])->void");
Expect.isFalse(c1.m3 is T4, "([int,int])->void is not (int,[int,int])->void");
Expect.isFalse(c1.m3 is T5, "([int,int])->void is not ([int,int,int])->void");
Expect.isTrue(c1.m4 is T1, "(int,[int,int])->void is (int,int)->void");
Expect.isTrue(c1.m4 is T2, "(int,[int,int])->void is (int,[int])->void");
Expect.isFalse(c1.m4 is T3, "(int,[int,int])->void is not ([int,int])->void");
Expect.isTrue(c1.m4 is T4, "(int,[int,int])->void is (int,[int,int])->void");
Expect.isFalse(
c1.m4 is T5, "(int,[int,int])->void is not ([int,int,int])->void");
Expect.isTrue(c1.m5 is T1, "([int,int,int])->void is (int,int)->void");
Expect.isTrue(c1.m5 is T2, "([int,int,int])->void is (int,[int])->void");
Expect.isTrue(c1.m5 is T3, "([int,int,int])->void is ([int,int])->void");
Expect.isTrue(c1.m5 is T4, "([int,int,int])->void is (int,[int,int])->void");
Expect.isTrue(c1.m5 is T5, "([int,int,int])->void is ([int,int,int])->void");
var c2 = new C<int, double, int>();
Expect.isFalse(c2.m1 is T1, "(int,double)->void is not (int,int)->void");
Expect.isFalse(
c2.m1 is T2, "(int,double)->void is not not (int,[int])->void");
Expect.isFalse(c2.m1 is T3, "(int,double)->void is not ([int,int])->void");
Expect.isFalse(
c2.m1 is T4, "(int,double)->void is not (int,[int,int])->void");
Expect.isFalse(
c2.m1 is T5, "(int,double)->void is not ([int,int,int])->void");
Expect.isFalse(c2.m2 is T1, "(int,[double])->void is not (int,int)->void");
Expect.isFalse(c2.m2 is T2, "(int,[double])->void is not (int,[int])->void");
Expect.isFalse(c2.m2 is T3, "(int,[double])->void is not ([int,int])->void");
Expect.isFalse(
c2.m2 is T4, "(int,[double])->void is not (int,[int,int])->void");
Expect.isFalse(
c2.m2 is T5, "(int,[double])->void is not ([int,int,int])->void");
Expect.isFalse(c2.m3 is T1, "([int,double])->void is not (int,int)->void");
Expect.isFalse(c2.m3 is T2, "([int,double])->void is not (int,[int])->void");
Expect.isFalse(c2.m3 is T3, "([int,double])->void is not ([int,int])->void");
Expect.isFalse(
c2.m3 is T4, "([int,double])->void is not (int,[int,int])->void");
Expect.isFalse(
c2.m3 is T5, "([int,double])->void is not ([int,int,int])->void");
Expect.isFalse(
c2.m4 is T1, "(int,[double,int])->void is not (int,int)->void");
Expect.isFalse(
c2.m4 is T2, "(int,[double,int])->void is not (int,[int])->void");
Expect.isFalse(
c2.m4 is T3, "(int,[double,int])->void is not ([int,int])->void");
Expect.isFalse(
c2.m4 is T4, "(int,[double,int])->void is (int,[int,int])->void");
Expect.isFalse(
c2.m4 is T5, "(int,[double,int])->void is ([int,int,int])->void");
Expect.isFalse(
c2.m5 is T1, "([int,double,int])->void is not (int,int)->void");
Expect.isFalse(
c2.m5 is T2, "([int,double,int])->void is not (int,[int])->void");
Expect.isFalse(
c2.m5 is T3, "([int,double,int])->void is not ([int,int])->void");
Expect.isFalse(
c2.m5 is T4, "([int,double,int])->void is (int,[int,int])->void");
Expect.isFalse(
c2.m5 is T5, "([int,double,int])->void is ([int,int,int])->void");
var c3 = new C<int, int, double>();
Expect.isTrue(c3.m1 is T1, "(int,int)->void is (int,int)->void");
Expect.isFalse(c3.m1 is T2, "(int,int)->void is not (int,[int])->void");
Expect.isFalse(c3.m1 is T3, "(int,int)->void is not ([int,int])->void");
Expect.isFalse(c3.m1 is T4, "(int,int)->void is not (int,[int,int])->void");
Expect.isFalse(c3.m1 is T5, "(int,int)->void is not ([int,int,int])->void");
Expect.isTrue(c3.m2 is T1, "(int,[int])->void is (int,int)->void");
Expect.isTrue(c3.m2 is T2, "(int,[int])->void is (int,[int])->void");
Expect.isFalse(c3.m2 is T3, "(int,[int])->void is not ([int,int])->void");
Expect.isFalse(c3.m2 is T4, "(int,[int])->void is not (int,[int,int])->void");
Expect.isFalse(c3.m2 is T5, "(int,[int])->void is not ([int,int,int])->void");
Expect.isTrue(c3.m3 is T1, "([int,int])->void is (int,int)->void");
Expect.isTrue(c3.m3 is T2, "([int,int])->void is (int,[int])->void");
Expect.isTrue(c3.m3 is T3, "([int,int])->void is ([int,int])->void");
Expect.isFalse(c3.m3 is T4, "([int,int])->void is not (int,[int,int])->void");
Expect.isFalse(c3.m3 is T5, "([int,int])->void is not ([int,int,int])->void");
Expect.isTrue(c3.m4 is T1, "(int,[int,double])->void is (int,int)->void");
Expect.isTrue(c3.m4 is T2, "(int,[int,double])->void is (int,[int])->void");
Expect.isFalse(
c3.m4 is T3, "(int,[int,double])->void is not ([int,int])->void");
Expect.isFalse(
c3.m4 is T4, "(int,[int,double])->void is (int,[int,int])->void");
Expect.isFalse(
c3.m4 is T5, "(int,[int,double])->void is ([int,int,int])->void");
Expect.isTrue(c3.m5 is T1, "([int,int,double])->void is (int,int)->void");
Expect.isTrue(c3.m5 is T2, "([int,int,double])->void is (int,[int])->void");
Expect.isTrue(c3.m5 is T3, "([int,int,double])->void is ([int,int])->void");
Expect.isFalse(
c3.m5 is T4, "([int,int,double])->void is (int,[int,int])->void");
Expect.isFalse(
c3.m5 is T5, "([int,int,double])->void is ([int,int,int])->void");
}