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

Unified Diff: test/codegen/language/async_return_types_test.dart

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
Index: test/codegen/language/async_return_types_test.dart
diff --git a/test/codegen/language/async_return_types_test.dart b/test/codegen/language/async_return_types_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..83eb9a8d992f441ece1e655ef2cece1056798739
--- /dev/null
+++ b/test/codegen/language/async_return_types_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2015, 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.
+
+import "dart:async";
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+Future foo1() async {
+ return 3;
+}
+
+Future<int> foo2() async {
+ return 3;
+}
+
+Future<int> /// wrongTypeParameter: static type warning
+foo3() async {
+ return "String";
+}
+
+// Future<int, String> is treated like Future<dynamic>
+Future<int, String> /// tooManyTypeParameters: static type warning
+foo4() async {
+ return "String";
+}
+
+int /// wrongReturnType: static type warning, dynamic type error
+foo5() async {
+ return 3;
+}
+
+Future<int> foo6() async {
+ // This is fine, the future is flattened
+ return new Future<int>.value(3);
+}
+
+Future<Future<int>> /// nestedFuture: static type warning
+foo7() async {
+ return new Future<int>.value(3);
+}
+
+test() async {
+ Expect.equals(3, await foo1());
+ Expect.equals(3, await foo2());
+ Expect.equals("String", await foo3());
+ Expect.equals("String", await foo4());
+ Expect.equals(3, await foo5());
+ Expect.equals(3, await await foo6());
+ Expect.equals(3, await await foo7());
+}
+
+main() {
+ asyncTest(test);
+}
« no previous file with comments | « test/codegen/language/async_rethrow_test.dart ('k') | test/codegen/language/async_star_cancel_and_throw_in_finally_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698