Chromium Code Reviews| 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 | 5 // VMOptions=--enable_async --optimization-counter-threshold=10 |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| 11 expectThenValue(future, value) { | 11 expectThenValue(future, value) { |
| 12 Expect.isTrue(future is Future); | 12 Expect.isTrue(future is Future); |
| 13 future.then((result) { | 13 future.then((result) { |
| 14 Expect.equals(value, result); | 14 Expect.equals(value, result); |
| 15 }); | 15 }); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 asyncImplicitReturn() async { | 63 asyncImplicitReturn() async { |
| 64 try {} | 64 try {} |
| 65 catch (e) {} | 65 catch (e) {} |
| 66 finally {} | 66 finally {} |
| 67 } | 67 } |
| 68 | 68 |
| 69 main() { | 69 main() { |
| 70 var asyncReturn; | 70 var asyncReturn; |
|
srdjan
2014/08/13 16:49:33
You can put this in a loop with 10 iterations to m
Michael Lippautz (Google)
2014/08/13 17:13:56
Done.
| |
| 71 | 71 |
| 72 asyncReturn = asyncIf(true); | 72 asyncReturn = asyncIf(true); |
| 73 expectThenValue(asyncReturn, 1); | 73 expectThenValue(asyncReturn, 1); |
| 74 asyncReturn = asyncIf(false); | 74 asyncReturn = asyncIf(false); |
| 75 expectThenValue(asyncReturn, 2); | 75 expectThenValue(asyncReturn, 2); |
| 76 | 76 |
| 77 asyncReturn = asyncFor(true); | 77 asyncReturn = asyncFor(true); |
| 78 expectThenValue(asyncReturn, 1); | 78 expectThenValue(asyncReturn, 1); |
| 79 asyncReturn = asyncFor(false); | 79 asyncReturn = asyncFor(false); |
| 80 expectThenValue(asyncReturn, 2); | 80 expectThenValue(asyncReturn, 2); |
| 81 | 81 |
| 82 asyncReturn = asyncTryCatchFinally(true, false); | 82 asyncReturn = asyncTryCatchFinally(true, false); |
| 83 expectThenValue(asyncReturn, 3); | 83 expectThenValue(asyncReturn, 3); |
| 84 asyncReturn = asyncTryCatchFinally(false, false); | 84 asyncReturn = asyncTryCatchFinally(false, false); |
| 85 expectThenValue(asyncReturn, 1); | 85 expectThenValue(asyncReturn, 1); |
| 86 asyncReturn = asyncTryCatchFinally(true, true); | 86 asyncReturn = asyncTryCatchFinally(true, true); |
| 87 expectThenValue(asyncReturn, 3); | 87 expectThenValue(asyncReturn, 3); |
| 88 asyncReturn = asyncTryCatchFinally(false, true); | 88 asyncReturn = asyncTryCatchFinally(false, true); |
| 89 expectThenValue(asyncReturn, 444); | 89 expectThenValue(asyncReturn, 444); |
| 90 asyncReturn = asyncTryCatchLoop(); | 90 asyncReturn = asyncTryCatchLoop(); |
| 91 expectThenValue(asyncReturn, 13); | 91 expectThenValue(asyncReturn, 13); |
| 92 | 92 |
| 93 asyncReturn = asyncImplicitReturn(); | 93 asyncReturn = asyncImplicitReturn(); |
| 94 expectThenValue(asyncReturn, null); | 94 expectThenValue(asyncReturn, null); |
| 95 } | 95 } |
| OLD | NEW |