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

Side by Side Diff: tests/language/await_future_test.dart

Issue 484933003: Await it! (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/symbols.h ('k') | tests/standalone/issue14236_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // VMOptions=--enable_async --optimization-counter-threshold=5
6
7 import 'package:expect/expect.dart';
8
9 import 'dart:async';
10
11 // It does not matter where a future is generated.
12 bar(p) async => p;
13 baz(p) => new Future(() => p);
14
15 foo() async {
16 var b = 0;
17 for(int i = 0; i < 10; i++) {
18 b += (await bar(1)) + (await baz(2));
19 }
20 return b;
21 }
22
23 quaz(p) async {
24 var x = 0;
25 try {
26 for (var j = 0; j < 10; j++) {
27 x += await baz(j);
28 }
29 return x;
30 } finally {
31 Expect.equals(x, 45);
32 return p;
33 }
34 }
35
36 quazz() async {
37 var x = 0;
38 try {
39 try {
40 x = await bar(1);
41 throw x;
42 } catch (e1) {
43 var y = await baz(e1 + 1);
44 throw y;
45 }
46 } catch (e2) {
47 return e2;
48 }
49 }
50
51 main() async {
52 var result;
53 for (int i = 0; i < 10; i++) {
54 result = await foo();
55 Expect.equals(result, 30);
56 result = await quaz(17);
57 Expect.equals(result, 17);
58 result = await quazz();
59 Expect.equals(result, 2);
60 }
61 }
OLDNEW
« no previous file with comments | « runtime/vm/symbols.h ('k') | tests/standalone/issue14236_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698