mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:01:19 +00:00
c10e96ba2f
Change-Id: I9daeebde586a00169bdaf069c7dc2fdc5d3d97f2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147160 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
62 lines
1.3 KiB
Dart
62 lines
1.3 KiB
Dart
// Copyright (c) 2016, 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
var _str = new StringBuffer();
|
|
|
|
T run<T>(T f()) {
|
|
_str.write("+");
|
|
var t = f();
|
|
_str.write("-");
|
|
return t;
|
|
}
|
|
|
|
void writeV() {
|
|
_str.write("V");
|
|
}
|
|
|
|
main() {
|
|
{
|
|
var x = run<dynamic>(writeV);
|
|
Expect.equals('+V-', _str.toString());
|
|
Expect.equals(null, x);
|
|
_str.clear();
|
|
|
|
var y = run(writeV) as dynamic;
|
|
Expect.equals('+V-', _str.toString());
|
|
Expect.equals(null, y);
|
|
_str.clear();
|
|
}
|
|
|
|
// implicit cast
|
|
{
|
|
dynamic d = writeV;
|
|
var x = run<dynamic>(d);
|
|
Expect.equals('+V-', _str.toString());
|
|
Expect.equals(null, x);
|
|
_str.clear();
|
|
|
|
var y = run(d);
|
|
Expect.equals('+V-', _str.toString());
|
|
Expect.equals(null, y);
|
|
_str.clear();
|
|
}
|
|
|
|
// dynamic dispatch
|
|
{
|
|
dynamic d = run;
|
|
var x = d<dynamic>(writeV);
|
|
Expect.equals('+V-', _str.toString());
|
|
Expect.equals(null, x);
|
|
_str.clear();
|
|
|
|
var y = d(writeV);
|
|
Expect.equals('+V-', _str.toString());
|
|
Expect.equals(null, y);
|
|
_str.clear();
|
|
}
|
|
}
|