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

Unified Diff: tests/language_2/void_type_callbacks_test.dart

Issue 2997353002: Adding adjusted `void` tests from CL 2699073003 (Closed)
Patch Set: Rebased Created 3 years, 4 months 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 | « tests/language_2/language_2_dartdevc.status ('k') | tests/language_2/void_type_function_types_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language_2/void_type_callbacks_test.dart
diff --git a/tests/language_2/void_type_callbacks_test.dart b/tests/language_2/void_type_callbacks_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ea6fe9e2eba422d3d76a3bd37b4c2ccb85fb6958
--- /dev/null
+++ b/tests/language_2/void_type_callbacks_test.dart
@@ -0,0 +1,40 @@
+// 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 callbacks and the type void.
+
+import 'package:expect/expect.dart';
+
+class A<T> {
+ T x;
+
+ foo(T x) {
+ }
+
+ T bar(T f()) {
+ T tmp = f();
+ return tmp;
+ }
+
+ gee(T f()) {
+ x = bar(f);
+ }
+
+ Object xAsObject() => x;
+}
+
+void voidFun() => 499;
+int intFun() => 42;
+
+main() {
+ A<void> a = new A<void>();
+ a.foo(a.x); //# 00: compile-time error
+ a.bar(voidFun);
+ Expect.equals(null, a.xAsObject());
+ a.x = a.bar(voidFun); //# 01: compile-time error
+ a.gee(voidFun);
+ Expect.equals(499, a.xAsObject());
+ a.gee(intFun);
+ Expect.equals(42, a.xAsObject());
+}
« no previous file with comments | « tests/language_2/language_2_dartdevc.status ('k') | tests/language_2/void_type_function_types_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698