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

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

Issue 537623002: Enable await in more statements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 --optimization-counter-threshold=5 5 // VMOptions=--enable_async --optimization-counter-threshold=5
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
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 var a = await y(); 63 var a = await y();
64 throw a; 64 throw a;
65 } catch (e2) { 65 } catch (e2) {
66 throw e2 + 1; 66 throw e2 + 1;
67 } 67 }
68 } catch (e3) { 68 } catch (e3) {
69 return e3; 69 return e3;
70 } 70 }
71 } 71 }
72 72
73 awaitIf(p) async {
74 if (p < (await bar(5))) {
75 return "p<5";
76 } else {
77 return "p>=5";
78 }
79 }
80
81 awaitNestedIf(p,q) async {
82 if (p == (await bar(5))) {
83 if (q < (await bar(7))) {
84 return "q<7";
85 } else {
86 return "q>=7";
87 }
88 } else {
89 return "p!=5";
90 }
91 return "!";
92 }
93
94 awaitElseIf(p) async {
95 if (p > (await bar(5))) {
96 return "p>5";
97 } else if (p < (await bar(5))) {
98 return "p<5";
99 } else {
100 return "p==5";
101 }
102 return "!";
103 }
104
105 awaitReturn() async {
106 return await bar(17);
107 }
108
109 awaitSwitch() async {
110 switch(await bar(3)) {
111 case 1:
112 return 1;
113 break;
114 case 3:
115 return 3;
116 break;
117 default:
118 return -1;
119 }
120 }
121
73 main() async { 122 main() async {
74 var result; 123 var result;
75 for (int i = 0; i < 10; i++) { 124 for (int i = 0; i < 10; i++) {
76 result = await foo(); 125 result = await foo();
77 Expect.equals(result, 30); 126 Expect.equals(result, 30);
78 result = await quaz(17); 127 result = await quaz(17);
79 Expect.equals(result, 17); 128 Expect.equals(result, 17);
80 result = await quazz(); 129 result = await quazz();
81 Expect.equals(result, 2); 130 Expect.equals(result, 2);
82 result = await nesting(); 131 result = await nesting();
83 Expect.equals(result, 5); 132 Expect.equals(result, 5);
133 result = await awaitIf(3);
134 Expect.equals(result, "p<5");
135 result = await awaitIf(5);
136 Expect.equals(result, "p>=5");
137 result = await awaitNestedIf(5,3);
138 Expect.equals(result, "q<7");
139 result = await awaitNestedIf(5,8);
140 Expect.equals(result, "q>=7");
141 result = await awaitNestedIf(3,8);
142 Expect.equals(result, "p!=5");
143 result = await awaitReturn();
144 Expect.equals(result, 17);
145 result = await awaitSwitch();
146 Expect.equals(result, 3);
147 result = await awaitElseIf(6);
148 Expect.equals(result, "p>5");
149 result = await awaitElseIf(4);
150 Expect.equals(result, "p<5");
151 result = await awaitElseIf(5);
152 Expect.equals(result, "p==5");
84 } 153 }
85 } 154 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698