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

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

Issue 964553004: Analyze locals in await for loops as inside a try-finally. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:async";
6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart";
8
9 sumStream(s) async {
10 int accum = 0;
11 await for (var v in s) {
12 accum += v;
13 }
14 return accum;
15 }
16
17 test() async {
18 var countStreamController;
19 int i = 0;
20 void tick() {
21 if (i < 10) {
22 countStreamController.add(i);
23 i++;
24 scheduleMicrotask(tick);
25 } else {
26 countStreamController.close();
27 }
28 }
29
30 countStreamController = new StreamController(
31 onListen: () {
32 scheduleMicrotask(tick);
33 });
34 Expect.equals(45, await sumStream(countStreamController.stream));
35 }
36
37 void main() {
38 asyncStart();
39 test().then((_) => asyncEnd());
40 }
OLDNEW
« pkg/compiler/lib/src/ssa/builder.dart ('K') | « pkg/compiler/lib/src/ssa/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698