Skip to content

Commit 180107c

Browse files
author
Jennifer Messerly
committed
add test, fixes #27807
this appears to have been already working correctly [email protected] Review URL: https://codereview.chromium.org/2517193004 .
1 parent de9e3a3 commit 180107c

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
// Dart test for type checks involving the void type.
5+
6+
import "package:expect/expect.dart";
7+
8+
var _str = new StringBuffer();
9+
10+
/*=T*/ run/*<T>*/(/*=T*/ f()) {
11+
_str.write("+");
12+
var t = f();
13+
_str.write("-");
14+
return t;
15+
}
16+
17+
void writeV() { _str.write("V"); }
18+
19+
main() {
20+
{
21+
var x = run/*<dynamic>*/(writeV);
22+
Expect.equals('+V-', _str.toString());
23+
Expect.equals(null, x);
24+
_str.clear();
25+
26+
var y = run(writeV);
27+
Expect.equals('+V-', _str.toString());
28+
Expect.equals(null, y);
29+
_str.clear();
30+
}
31+
32+
// implicit cast
33+
{
34+
dynamic d = writeV;
35+
var x = run/*<dynamic>*/(d);
36+
Expect.equals('+V-', _str.toString());
37+
Expect.equals(null, x);
38+
_str.clear();
39+
40+
var y = run(d);
41+
Expect.equals('+V-', _str.toString());
42+
Expect.equals(null, y);
43+
_str.clear();
44+
}
45+
46+
// dynamic dispatch
47+
{
48+
dynamic d = run;
49+
var x = d/*<dynamic>*/(writeV);
50+
Expect.equals('+V-', _str.toString());
51+
Expect.equals(null, x);
52+
_str.clear();
53+
54+
var y = d(writeV);
55+
Expect.equals('+V-', _str.toString());
56+
Expect.equals(null, y);
57+
_str.clear();
58+
}
59+
}

0 commit comments

Comments
 (0)