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

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

Issue 538703002: Enable await in while and do-while. (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
« runtime/vm/parser.cc ('K') | « 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return 1; 112 return 1;
113 break; 113 break;
114 case 3: 114 case 3:
115 return 3; 115 return 3;
116 break; 116 break;
117 default: 117 default:
118 return -1; 118 return -1;
119 } 119 }
120 } 120 }
121 121
122 awaitNestedWhile(int i, int j) async {
123 int savedJ = j;
124 var decI = () async {
125 return i--;
126 };
127 var decJ = () async {
128 return j--;
129 };
130 var k = 0;
131 while ((await decI()) > 0) {
132 j = savedJ;
133 while(0 < (await decJ())) {
134 k++;
135 }
136 }
137 return k;
138 }
139
140 awaitNestedDoWhile(int i, int j) async {
141 int savedJ = j;
142 var decI = () async {
143 return i--;
144 };
145 var decJ = () async {
146 return j--;
147 };
148 var k = 0;
149 do {
150 do {
151 k++;
152 } while (0 < (await decI()));
153 } while((await decJ()) > 0);
154 return k;
155 }
156
122 main() async { 157 main() async {
123 var result; 158 var result;
124 for (int i = 0; i < 10; i++) { 159 for (int i = 0; i < 10; i++) {
125 result = await foo(); 160 result = await foo();
126 Expect.equals(result, 30); 161 Expect.equals(30, result);
127 result = await quaz(17); 162 result = await quaz(17);
128 Expect.equals(result, 17); 163 Expect.equals(17, result);
129 result = await quazz(); 164 result = await quazz();
130 Expect.equals(result, 2); 165 Expect.equals(2, result);
131 result = await nesting(); 166 result = await nesting();
132 Expect.equals(result, 5); 167 Expect.equals(5, result);
133 result = await awaitIf(3); 168 result = await awaitIf(3);
134 Expect.equals(result, "p<5"); 169 Expect.equals("p<5", result);
135 result = await awaitIf(5); 170 result = await awaitIf(5);
136 Expect.equals(result, "p>=5"); 171 Expect.equals("p>=5", result);
137 result = await awaitNestedIf(5,3); 172 result = await awaitNestedIf(5,3);
138 Expect.equals(result, "q<7"); 173 Expect.equals("q<7", result);
139 result = await awaitNestedIf(5,8); 174 result = await awaitNestedIf(5,8);
140 Expect.equals(result, "q>=7"); 175 Expect.equals("q>=7", result);
141 result = await awaitNestedIf(3,8); 176 result = await awaitNestedIf(3,8);
142 Expect.equals(result, "p!=5"); 177 Expect.equals("p!=5", result);
143 result = await awaitReturn(); 178 result = await awaitReturn();
144 Expect.equals(result, 17); 179 Expect.equals(17, result);
145 result = await awaitSwitch(); 180 result = await awaitSwitch();
146 Expect.equals(result, 3); 181 Expect.equals(3, result);
147 result = await awaitElseIf(6); 182 result = await awaitElseIf(6);
148 Expect.equals(result, "p>5"); 183 Expect.equals("p>5", result);
149 result = await awaitElseIf(4); 184 result = await awaitElseIf(4);
150 Expect.equals(result, "p<5"); 185 Expect.equals("p<5", result);
151 result = await awaitElseIf(5); 186 result = await awaitElseIf(5);
152 Expect.equals(result, "p==5"); 187 Expect.equals("p==5", result);
188 result = await awaitNestedWhile(5,3);
189 Expect.equals(15, result);
190 result = await awaitNestedWhile(4,6);
191 Expect.equals(24, result);
153 } 192 }
154 } 193 }
OLDNEW
« runtime/vm/parser.cc ('K') | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698