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

Side by Side Diff: tests/language_strong/await_for_use_local_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import "dart:async"; 5 import "dart:async";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 8
9 sumStream(s) async { 9 sumStream(s) async {
10 int accum = 0; 10 int accum = 0;
11 await for (var v in s) { 11 await for (var v in s) {
12 accum += v; 12 accum += v;
13 } 13 }
14 return accum; 14 return accum;
15 } 15 }
16 16
17 test() async { 17 test() async {
18 var countStreamController; 18 var countStreamController;
19 int i = 0; 19 int i = 0;
20 void tick() { 20 void tick() {
21 if (i < 10) { 21 if (i < 10) {
22 countStreamController.add(i); 22 countStreamController.add(i);
23 i++; 23 i++;
24 scheduleMicrotask(tick); 24 scheduleMicrotask(tick);
25 } else { 25 } else {
26 countStreamController.close(); 26 countStreamController.close();
27 } 27 }
28 } 28 }
29 29
30 countStreamController = new StreamController( 30 countStreamController = new StreamController(onListen: () {
31 onListen: () { 31 scheduleMicrotask(tick);
32 scheduleMicrotask(tick); 32 });
33 });
34 Expect.equals(45, await sumStream(countStreamController.stream)); 33 Expect.equals(45, await sumStream(countStreamController.stream));
35 } 34 }
36 35
37 void main() { 36 void main() {
38 asyncStart(); 37 asyncStart();
39 test().then((_) => asyncEnd()); 38 test().then((_) => asyncEnd());
40 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698