OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 topLevelFunction() async {} | 9 topLevelFunction() async {} |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 class B { | 40 class B { |
41 final _y; | 41 final _y; |
42 const B._internal(this._y); | 42 const B._internal(this._y); |
43 | 43 |
44 B() : _y = null; | 44 B() : _y = null; |
45 } | 45 } |
46 | 46 |
47 main() { | 47 main() { |
48 var asyncReturn; | 48 Future asyncReturn; |
49 | 49 |
50 asyncReturn = topLevelFunction(); | 50 asyncReturn = topLevelFunction(); |
51 Expect.isTrue(asyncReturn is Future); | 51 Expect.isTrue(asyncReturn is Future); |
52 | 52 |
53 asyncReturn = topLevelWithParameter(4); | 53 asyncReturn = topLevelWithParameter(4); |
54 Expect.isTrue(asyncReturn is Future); | 54 Expect.isTrue(asyncReturn is Future); |
55 asyncReturn.then((int result) => Expect.equals(result, 11)); | 55 asyncReturn.then((int result) => Expect.equals(result, 11)); |
56 | 56 |
57 asyncReturn = topLevelGetter; | 57 asyncReturn = topLevelGetter; |
58 Expect.isTrue(asyncReturn is Future); | 58 Expect.isTrue(asyncReturn is Future); |
(...skipping 28 matching lines...) Expand all Loading... |
87 var moreNesting = (int shadowP1, String p2, num p3) { | 87 var moreNesting = (int shadowP1, String p2, num p3) { |
88 var z = 3; | 88 var z = 3; |
89 aa(int shadowP1) async { | 89 aa(int shadowP1) async { |
90 return foo + z + p3 + shadowP1; | 90 return foo + z + p3 + shadowP1; |
91 } | 91 } |
92 | 92 |
93 return aa(6); | 93 return aa(6); |
94 }; | 94 }; |
95 asyncReturn = moreNesting(1, "ignore", 2); | 95 asyncReturn = moreNesting(1, "ignore", 2); |
96 Expect.isTrue(asyncReturn is Future); | 96 Expect.isTrue(asyncReturn is Future); |
97 asyncReturn.then((int result) => Expect.equals(result, 28)); | 97 asyncReturn.then((num result) => Expect.equals(result, 28)); |
98 | 98 |
99 var checkAsync = (var someFunc) { | 99 var checkAsync = (var someFunc) { |
100 var toTest = someFunc(); | 100 var toTest = someFunc(); |
101 Expect.isTrue(toTest is Future); | 101 Expect.isTrue(toTest is Future); |
102 toTest.then((int result) => Expect.equals(result, 4)); | 102 toTest.then((int result) => Expect.equals(result, 4)); |
103 }; | 103 }; |
104 checkAsync(() async => 4); | 104 checkAsync(() async => 4); |
105 } | 105 } |
OLD | NEW |