| 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 // VMOptions=--enable_async | |
| 6 | 5 |
| 7 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 8 | 7 |
| 9 import 'dart:async'; | 8 import 'dart:async'; |
| 10 | 9 |
| 11 topLevelFunction() async { } | 10 topLevelFunction() async { } |
| 12 | 11 |
| 13 Future<int> topLevelWithParameter(int a) async { | 12 Future<int> topLevelWithParameter(int a) async { |
| 14 return 7 + a; | 13 return 7 + a; |
| 15 } | 14 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 asyncReturn = a.getter; /// type-mismatch4: static type warning, dynamic type
error | 88 asyncReturn = a.getter; /// type-mismatch4: static type warning, dynamic type
error |
| 90 Expect.isTrue(asyncReturn is Future); /// type-mismatch4: continued | 89 Expect.isTrue(asyncReturn is Future); /// type-mismatch4: continued |
| 91 asyncReturn.then((int result) => Expect.equals(result, 18)); /// type-mismatc
h4: continued | 90 asyncReturn.then((int result) => Expect.equals(result, 18)); /// type-mismatc
h4: continued |
| 92 | 91 |
| 93 var b = new A(9); | 92 var b = new A(9); |
| 94 asyncReturn = a + b; | 93 asyncReturn = a + b; |
| 95 Expect.isTrue(asyncReturn is Future); | 94 Expect.isTrue(asyncReturn is Future); |
| 96 asyncReturn.then((A result) => Expect.equals(result.value, 22)); | 95 asyncReturn.then((A result) => Expect.equals(result.value, 22)); |
| 97 | 96 |
| 98 var foo = 17; | 97 var foo = 17; |
| 99 bar(int p1, p2) async { | 98 bar(int p1, p2) async { |
| 100 var z = 8; | 99 var z = 8; |
| 101 return p2 + z + foo; | 100 return p2 + z + foo; |
| 102 } | 101 } |
| 103 asyncReturn = bar(1,2); | 102 asyncReturn = bar(1,2); |
| 104 Expect.isTrue(asyncReturn is Future); | 103 Expect.isTrue(asyncReturn is Future); |
| 105 asyncReturn.then((int result) => Expect.equals(result, 27)); | 104 asyncReturn.then((int result) => Expect.equals(result, 27)); |
| 106 | 105 |
| 107 var moreNesting = (int shadowP1, String p2, num p3) { | 106 var moreNesting = (int shadowP1, String p2, num p3) { |
| 108 var z = 3; | 107 var z = 3; |
| 109 aa(int shadowP1) async { | 108 aa(int shadowP1) async { |
| 110 return foo + z + p3 + shadowP1; | 109 return foo + z + p3 + shadowP1; |
| 111 } | 110 } |
| 112 return aa(6); | 111 return aa(6); |
| 113 }; | 112 }; |
| 114 asyncReturn = moreNesting(1, "ignore", 2); | 113 asyncReturn = moreNesting(1, "ignore", 2); |
| 115 Expect.isTrue(asyncReturn is Future); | 114 Expect.isTrue(asyncReturn is Future); |
| 116 asyncReturn.then((int result) => Expect.equals(result, 28)); | 115 asyncReturn.then((int result) => Expect.equals(result, 28)); |
| 117 | 116 |
| 118 var b1 = const B.createConst(4); /// constructor4: compile-time error | 117 var b1 = const B.createConst(4); /// constructor4: compile-time error |
| 119 var b2 = new B(); | 118 var b2 = new B(); |
| 120 b2.dontDoThat = 4; /// setter1: compile-time error | 119 b2.dontDoThat = 4; /// setter1: compile-time error |
| 121 | 120 |
| 122 var checkAsync = (var someFunc) { | 121 var checkAsync = (var someFunc) { |
| 123 var toTest = someFunc(); | 122 var toTest = someFunc(); |
| 124 Expect.isTrue(toTest is Future); | 123 Expect.isTrue(toTest is Future); |
| 125 toTest.then((int result) => Expect.equals(result, 4)); | 124 toTest.then((int result) => Expect.equals(result, 4)); |
| 126 }; | 125 }; |
| 127 checkAsync(() async => 4); | 126 checkAsync(() async => 4); |
| 128 | 127 |
| 129 } | 128 } |
| OLD | NEW |