mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:43:32 +00:00
1a832455e6
Change-Id: I4fc4bc583f6fe25a0a083efc6b9cda5ef9ae5ceb Reviewed-on: https://dart-review.googlesource.com/66521 Commit-Queue: Leaf Petersen <leafp@google.com> Reviewed-by: Erik Ernst <eernst@google.com>
109 lines
2.4 KiB
Dart
109 lines
2.4 KiB
Dart
// Copyright (c) 2017, 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 for type checks involving the void type in function types.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
typedef F = void Function(Object);
|
|
typedef F2 = void Function([Object]);
|
|
typedef F3 = void Function({Object x});
|
|
|
|
typedef G = void Function(void);
|
|
typedef G2 = void Function([void]);
|
|
typedef G3 = void Function({void x});
|
|
|
|
typedef H = int Function(void);
|
|
typedef H2 = int Function([void]);
|
|
typedef H3 = int Function({void x});
|
|
|
|
void f(Object x) {}
|
|
void f2([Object x]) {}
|
|
void f3({Object x}) {}
|
|
|
|
void g(void x) {}
|
|
void g2([void x]) {}
|
|
void g3({void x}) {}
|
|
|
|
int h(void x) => 499;
|
|
int h2([void x]) => 499;
|
|
int h3({void x}) => 499;
|
|
|
|
void expectsF(F f) {}
|
|
void expectsG(G g) {}
|
|
void expectsH(H h) {}
|
|
|
|
void expectsF2(F2 f) {}
|
|
void expectsG2(G2 g) {}
|
|
void expectsH2(H2 h) {}
|
|
|
|
void expectsF3(F3 f) {}
|
|
void expectsG3(G3 g) {}
|
|
void expectsH3(H3 h) {}
|
|
|
|
main() {
|
|
Expect.isTrue(f is F);
|
|
Expect.isTrue(f is G);
|
|
Expect.isFalse(f is H);
|
|
expectsF(f);
|
|
expectsG(f);
|
|
expectsH(f); //# 00: compile-time error
|
|
|
|
Expect.isTrue(f2 is F2);
|
|
Expect.isTrue(f2 is G2);
|
|
Expect.isFalse(f2 is H2);
|
|
expectsF2(f2);
|
|
expectsG2(f2);
|
|
expectsH2(f2); //# 01: compile-time error
|
|
|
|
Expect.isTrue(f3 is F3);
|
|
Expect.isTrue(f3 is G3);
|
|
Expect.isFalse(f3 is H3);
|
|
expectsF3(f3);
|
|
expectsG3(f3);
|
|
expectsH3(f3); //# 03: compile-time error
|
|
|
|
Expect.isTrue(g is F);
|
|
Expect.isTrue(g is G);
|
|
Expect.isFalse(g is H);
|
|
expectsF(g);
|
|
expectsG(g);
|
|
expectsH(g); //# 05: compile-time error
|
|
|
|
Expect.isTrue(g2 is F2);
|
|
Expect.isTrue(g2 is G2);
|
|
Expect.isFalse(g2 is H2);
|
|
expectsF2(g2);
|
|
expectsG2(g2);
|
|
expectsH2(g2); //# 07: compile-time error
|
|
|
|
Expect.isTrue(g3 is F3);
|
|
Expect.isTrue(g3 is G3);
|
|
Expect.isFalse(g3 is H3);
|
|
expectsF3(g3);
|
|
expectsG3(g3);
|
|
expectsH3(g3); //# 09: compile-time error
|
|
|
|
Expect.isTrue(h is F);
|
|
Expect.isTrue(h is G);
|
|
Expect.isTrue(h is H);
|
|
expectsF(h);
|
|
expectsG(h);
|
|
expectsH(h);
|
|
|
|
Expect.isTrue(h2 is F2);
|
|
Expect.isTrue(h2 is G2);
|
|
Expect.isTrue(h2 is H2);
|
|
expectsF2(h2);
|
|
expectsG2(h2);
|
|
expectsH2(h2);
|
|
|
|
Expect.isTrue(h3 is F3);
|
|
Expect.isTrue(h3 is G3);
|
|
Expect.isTrue(h3 is H3);
|
|
expectsF3(h3);
|
|
expectsG3(h3);
|
|
expectsH3(h3);
|
|
}
|