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

Side by Side Diff: tests/compiler/dart2js/async_await_js_transform_test.dart

Issue 1275003002: dart2js: Add a failing test case for the async rewriter. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comment. Created 5 years, 4 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | 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) 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "package:compiler/src/js/js.dart"; 6 import "package:compiler/src/js/js.dart";
7 import "package:compiler/src/js/rewrite_async.dart"; 7 import "package:compiler/src/js/rewrite_async.dart";
8 import "package:compiler/src/js_backend/js_backend.dart" show StringBackedName; 8 import "package:compiler/src/js_backend/js_backend.dart" show StringBackedName;
9 9
10 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener; 10 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener;
(...skipping 26 matching lines...) Expand all
37 null, 37 null,
38 endOfIteration: new VariableUse("endOfIteration"), 38 endOfIteration: new VariableUse("endOfIteration"),
39 newIterable: new VariableUse("newIterable"), 39 newIterable: new VariableUse("newIterable"),
40 yieldStarExpression: new VariableUse("yieldStar"), 40 yieldStarExpression: new VariableUse("yieldStar"),
41 uncaughtErrorExpression: new VariableUse("uncaughtError"), 41 uncaughtErrorExpression: new VariableUse("uncaughtError"),
42 safeVariableName: (String name) => "__$name", 42 safeVariableName: (String name) => "__$name",
43 bodyName: new StringBackedName("body"))); 43 bodyName: new StringBackedName("body")));
44 } 44 }
45 45
46 main() { 46 main() {
47 testAsyncTransform( /// 01: ok
48 r"""function() async {
49 var closures = [new A.main_closure()], v0 = await closures, v1 = 0, v2, v3;
50 if (v1 < 0 || v1 >= v0.length)
51 H.ioore(v0, v1);
52 v2 = 4;
53 v3 = 2;
54 P.print(v0[v1].call$2(v2, v3));
55 }"""
56 , /// 01: ok
57 r"""function() {
58 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, closures, v0, v1, v2, v3;
59 function body(__errorCode, __result) {
60 if (__errorCode === 1) {
61 __currentError = __result;
62 __goto = __handler;
63 }
64 while (true)
65 switch (__goto) {
66 case 0:
67 // Function start
68 __goto = 2;
69 closures = [new A.main_closure()];
70 return thenHelper(closures, body, __completer);
71 case 2:
72 // returning from await.
73 v0 = __result, v1 = 0;
74 if (v1 < 0 || v1 >= v0.length)
75 H.ioore(v0, v1);
76 else
77 ;
78 v2 = 4;
79 v3 = 2;
80 P.print(v0[v1].call$2(v2, v3));
81 // implicit return
82 return thenHelper(null, 0, __completer, null);
83 case 1:
84 // rethrow
85 return thenHelper(__currentError, 1, __completer);
86 }
87 }
88 return thenHelper(null, body, __completer, null);
89 }"""
90 ) /// 01: ok
91 ;
92
47 testAsyncTransform(""" 93 testAsyncTransform("""
48 function(a) async { 94 function(a) async {
49 print(this.x); // Ensure `this` is translated in the helper function. 95 print(this.x); // Ensure `this` is translated in the helper function.
50 await foo(); 96 await foo();
51 }""", """ 97 }""", """
52 function(a) { 98 function(a) {
53 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __self = this; 99 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __self = this;
54 function body(__errorCode, __result) { 100 function body(__errorCode, __result) {
55 if (__errorCode === 1) { 101 if (__errorCode === 1) {
56 __currentError = __result; 102 __currentError = __result;
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 // return 1231 // return
1186 return endOfIteration(); 1232 return endOfIteration();
1187 case 2: 1233 case 2:
1188 // rethrow 1234 // rethrow
1189 return uncaughtError(__currentError); 1235 return uncaughtError(__currentError);
1190 } 1236 }
1191 }; 1237 };
1192 }); 1238 });
1193 }"""); 1239 }""");
1194 } 1240 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698