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

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

Issue 508643004: Fix scope/context behavior in await transformer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add await_is_keyword_ indicator to parser 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
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 30 matching lines...) Expand all
41 throw x; 41 throw x;
42 } catch (e1) { 42 } catch (e1) {
43 var y = await baz(e1 + 1); 43 var y = await baz(e1 + 1);
44 throw y; 44 throw y;
45 } 45 }
46 } catch (e2) { 46 } catch (e2) {
47 return e2; 47 return e2;
48 } 48 }
49 } 49 }
50 50
51 var result = "";
52
53 reset() {
54 result = "";
55 }
56
57 observe(x) {
58 if (result.length > 0) {
59 result += ",";
60 }
61 result += x;
62 }
63
64 newTask(x) async => observe(x);
65
66 awaitAll(tasks) async {
67 for (var task in tasks) {
68 // This actually opens up a new context level.
69 await task;
70 }
71 }
72
73 taskTest() async {
74 var tasks = [ newTask('a'), newTask('b'), newTask('c') ];
75 reset();
76 await awaitAll(tasks);
77 Expect.equals('a,b,c', result);
78 }
79
51 main() async { 80 main() async {
52 var result; 81 var result;
53 for (int i = 0; i < 10; i++) { 82 for (int i = 0; i < 10; i++) {
54 result = await foo(); 83 result = await foo();
55 Expect.equals(result, 30); 84 Expect.equals(result, 30);
56 result = await quaz(17); 85 result = await quaz(17);
57 Expect.equals(result, 17); 86 Expect.equals(result, 17);
58 result = await quazz(); 87 result = await quazz();
59 Expect.equals(result, 2); 88 Expect.equals(result, 2);
89 await taskTest();
60 } 90 }
61 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698