OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:async"; | 5 import "dart:async"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
8 | 8 |
9 Future foo1() async { | 9 Future foo1() async { |
10 return 3; | 10 return 3; |
11 } | 11 } |
12 | 12 |
13 Future<int> foo2() async { | 13 Future<int> foo2() async { |
14 return 3; | 14 return 3; |
15 } | 15 } |
16 | 16 |
17 Future<int> /// wrongTypeParameter: static type warning | 17 Future<int> //# wrongTypeParameter: static type warning |
18 foo3() async { | 18 foo3() async { |
19 return "String"; | 19 return "String"; |
20 } | 20 } |
21 | 21 |
22 // Future<int, String> is treated like Future<dynamic> | 22 // Future<int, String> is treated like Future<dynamic> |
23 Future<int, String> /// tooManyTypeParameters: static type warning | 23 Future<int, String> //# tooManyTypeParameters: static type warning |
24 foo4() async { | 24 foo4() async { |
25 return "String"; | 25 return "String"; |
26 } | 26 } |
27 | 27 |
28 int /// wrongReturnType: static type warning, dynamic type error | 28 int //# wrongReturnType: static type warning, dynamic type error |
29 foo5() async { | 29 foo5() async { |
30 return 3; | 30 return 3; |
31 } | 31 } |
32 | 32 |
33 Future<int> foo6() async { | 33 Future<int> foo6() async { |
34 // This is fine, the future is flattened | 34 // This is fine, the future is flattened |
35 return new Future<int>.value(3); | 35 return new Future<int>.value(3); |
36 } | 36 } |
37 | 37 |
38 Future<Future<int>> /// nestedFuture: static type warning | 38 Future<Future<int>> //# nestedFuture: static type warning |
39 foo7() async { | 39 foo7() async { |
40 return new Future<int>.value(3); | 40 return new Future<int>.value(3); |
41 } | 41 } |
42 | 42 |
43 test() async { | 43 test() async { |
44 Expect.equals(3, await foo1()); | 44 Expect.equals(3, await foo1()); |
45 Expect.equals(3, await foo2()); | 45 Expect.equals(3, await foo2()); |
46 Expect.equals("String", await foo3()); | 46 Expect.equals("String", await foo3()); |
47 Expect.equals("String", await foo4()); | 47 Expect.equals("String", await foo4()); |
48 Expect.equals(3, await foo5()); | 48 Expect.equals(3, await foo5()); |
49 Expect.equals(3, await await foo6()); | 49 Expect.equals(3, await await foo6()); |
50 Expect.equals(3, await await foo7()); | 50 Expect.equals(3, await await foo7()); |
51 } | 51 } |
52 | 52 |
53 main() { | 53 main() { |
54 asyncTest(test); | 54 asyncTest(test); |
55 } | 55 } |
OLD | NEW |