Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: pkg/dev_compiler/test/codegen/language/void_subtype_test.dart

Issue 2517193004: add test, fixes #27807 (Closed)
Patch Set: moar tests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/test/codegen/language/void_subtype_test.dart
diff --git a/pkg/dev_compiler/test/codegen/language/void_subtype_test.dart b/pkg/dev_compiler/test/codegen/language/void_subtype_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f626232e657355c398a0f8df5fe5974177c05055
--- /dev/null
+++ b/pkg/dev_compiler/test/codegen/language/void_subtype_test.dart
@@ -0,0 +1,59 @@
+// 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);
+ 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();
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698