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

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

Issue 946353003: Use more js templates in async rewrite. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 5 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/js/rewrite_async.dart ('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) 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 8
9 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener; 9 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener;
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 main() { 30 main() {
31 testTransform(""" 31 testTransform("""
32 function(a) async { 32 function(a) async {
33 print(this.x); // Ensure `this` is translated in the helper function. 33 print(this.x); // Ensure `this` is translated in the helper function.
34 await foo(); 34 await foo();
35 }""", """ 35 }""", """
36 function(a) { 36 function(a) {
37 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __self = this; 37 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __self = this;
38 function __body(__errorCode, __result) { 38 function __body(__errorCode, __result) {
39 if (__errorCode == 1) { 39 if (__errorCode === 1) {
40 __currentError = __result; 40 __currentError = __result;
41 __goto = __handler; 41 __goto = __handler;
42 } 42 }
43 while (true) 43 while (true)
44 switch (__goto) { 44 switch (__goto) {
45 case 0: 45 case 0:
46 // Function start 46 // Function start
47 print(__self.x); 47 print(__self.x);
48 __goto = 2; 48 __goto = 2;
49 return thenHelper(foo(), __body, __completer); 49 return thenHelper(foo(), __body, __completer);
(...skipping 29 matching lines...) Expand all
79 } 79 }
80 } 80 }
81 } finally { 81 } finally {
82 return 3; // Return from finally with no pending finally. 82 return 3; // Return from finally with no pending finally.
83 } 83 }
84 return 4; 84 return 4;
85 }""", """ 85 }""", """
86 function(b) { 86 function(b) {
87 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __next, __returnValue, __helper; 87 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __next, __returnValue, __helper;
88 function __body(__errorCode, __result) { 88 function __body(__errorCode, __result) {
89 if (__errorCode == 1) { 89 if (__errorCode === 1) {
90 __currentError = __result; 90 __currentError = __result;
91 __goto = __handler; 91 __goto = __handler;
92 } 92 }
93 while (true) 93 while (true)
94 __outer1: 94 __outer1:
95 switch (__goto) { 95 switch (__goto) {
96 case 0: 96 case 0:
97 // Function start 97 // Function start
98 __handler = 3; 98 __handler = 3;
99 case 7: 99 case 7:
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 a = b++; // post- and preincrements. 191 a = b++; // post- and preincrements.
192 b = --b; 192 b = --b;
193 c = (await foo()).a++; 193 c = (await foo()).a++;
194 d = ++(await foo()).a; 194 d = ++(await foo()).a;
195 e = foo1()[await foo2()]--; 195 e = foo1()[await foo2()]--;
196 f = --foo1()[await foo2()]; 196 f = --foo1()[await foo2()];
197 }""", """ 197 }""", """
198 function(c) { 198 function(c) {
199 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, __temp1; 199 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, __temp1;
200 function __body(__errorCode, __result) { 200 function __body(__errorCode, __result) {
201 if (__errorCode == 1) { 201 if (__errorCode === 1) {
202 __currentError = __result; 202 __currentError = __result;
203 __goto = __handler; 203 __goto = __handler;
204 } 204 }
205 while (true) 205 while (true)
206 switch (__goto) { 206 switch (__goto) {
207 case 0: 207 case 0:
208 // Function start 208 // Function start
209 a = b++; 209 a = b++;
210 b = --b; 210 b = --b;
211 __goto = 2; 211 __goto = 2;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 c = await foo1() || foo3(await foo2()); 248 c = await foo1() || foo3(await foo2());
249 d = foo1() || foo2(); 249 d = foo1() || foo2();
250 e = foo1() && await foo2(); 250 e = foo1() && await foo2();
251 f = await foo1() && foo2(); 251 f = await foo1() && foo2();
252 g = await foo1() && await foo2(); 252 g = await foo1() && await foo2();
253 h = foo1() && foo2(); 253 h = foo1() && foo2();
254 }""", """ 254 }""", """
255 function(d2) { 255 function(d2) {
256 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, g, h, __temp1; 256 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, g, h, __temp1;
257 function __body(__errorCode, __result) { 257 function __body(__errorCode, __result) {
258 if (__errorCode == 1) { 258 if (__errorCode === 1) {
259 __currentError = __result; 259 __currentError = __result;
260 __goto = __handler; 260 __goto = __handler;
261 } 261 }
262 while (true) 262 while (true)
263 switch (__goto) { 263 switch (__goto) {
264 case 0: 264 case 0:
265 // Function start 265 // Function start
266 __temp1 = foo1(); 266 __temp1 = foo1();
267 if (__temp1) { 267 if (__temp1) {
268 // goto then 268 // goto then
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 await foo(); 385 await foo();
386 break; // Break the switch 386 break; // Break the switch
387 case 2: 387 case 2:
388 foo(); // No default 388 foo(); // No default
389 } 389 }
390 } 390 }
391 }""", """ 391 }""", """
392 function(x, y) { 392 function(x, y) {
393 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError; 393 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError;
394 function __body(__errorCode, __result) { 394 function __body(__errorCode, __result) {
395 if (__errorCode == 1) { 395 if (__errorCode === 1) {
396 __currentError = __result; 396 __currentError = __result;
397 __goto = __handler; 397 __goto = __handler;
398 } 398 }
399 while (true) 399 while (true)
400 switch (__goto) { 400 switch (__goto) {
401 case 0: 401 case 0:
402 // Function start 402 // Function start
403 case 2: 403 case 2:
404 // while condition 404 // while condition
405 case 4: 405 case 4:
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 if (a) // If with no awaits in body 472 if (a) // If with no awaits in body
473 break; 473 break;
474 else 474 else
475 continue; 475 continue;
476 } while (await foo()); 476 } while (await foo());
477 } 477 }
478 """, """ 478 """, """
479 function(f) { 479 function(f) {
480 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a; 480 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a;
481 function __body(__errorCode, __result) { 481 function __body(__errorCode, __result) {
482 if (__errorCode == 1) { 482 if (__errorCode === 1) {
483 __currentError = __result; 483 __currentError = __result;
484 __goto = __handler; 484 __goto = __handler;
485 } 485 }
486 while (true) 486 while (true)
487 switch (__goto) { 487 switch (__goto) {
488 case 0: 488 case 0:
489 // Function start 489 // Function start
490 case 2: 490 case 2:
491 // do body 491 // do body
492 __goto = 5; 492 __goto = 5;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 await foo(); 537 await foo();
538 return; 538 return;
539 } 539 }
540 print(await(foo(i))); 540 print(await(foo(i)));
541 } 541 }
542 } 542 }
543 """, """ 543 """, """
544 function(g) { 544 function(g) {
545 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __returnValue, i, __temp1; 545 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __returnValue, i, __temp1;
546 function __body(__errorCode, __result) { 546 function __body(__errorCode, __result) {
547 if (__errorCode == 1) { 547 if (__errorCode === 1) {
548 __currentError = __result; 548 __currentError = __result;
549 __goto = __handler; 549 __goto = __handler;
550 } 550 }
551 while (true) 551 while (true)
552 switch (__goto) { 552 switch (__goto) {
553 case 0: 553 case 0:
554 // Function start 554 // Function start
555 i = 0; 555 i = 0;
556 case 3: 556 case 3:
557 // for condition 557 // for condition
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 x["a"] = 2; // Different assignments 622 x["a"] = 2; // Different assignments
623 (await foo()).a = 3; 623 (await foo()).a = 3;
624 x[await foo()] = 4; 624 x[await foo()] = 4;
625 x[(await foo1()).a = await foo2()] = 5; 625 x[(await foo1()).a = await foo2()] = 5;
626 (await foo1())[await foo2()] = await foo3(6); 626 (await foo1())[await foo2()] = await foo3(6);
627 } 627 }
628 """, """ 628 """, """
629 function(a, h) { 629 function(a, h) {
630 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, __temp1, __temp2; 630 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, __temp1, __temp2;
631 function __body(__errorCode, __result) { 631 function __body(__errorCode, __result) {
632 if (__errorCode == 1) { 632 if (__errorCode === 1) {
633 __currentError = __result; 633 __currentError = __result;
634 __goto = __handler; 634 __goto = __handler;
635 } 635 }
636 while (true) 636 while (true)
637 switch (__goto) { 637 switch (__goto) {
638 case 0: 638 case 0:
639 // Function start 639 // Function start
640 __temp1 = foo1(); 640 __temp1 = foo1();
641 __goto = 2; 641 __goto = 2;
642 return thenHelper(foo2(), __body, __completer); 642 return thenHelper(foo2(), __body, __completer);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 y.x = foo(error); 703 y.x = foo(error);
704 } finally { 704 } finally {
705 foo(x); 705 foo(x);
706 } 706 }
707 } 707 }
708 } 708 }
709 """, """ 709 """, """
710 function(c, i) { 710 function(c, i) {
711 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, y, __error1, __error2; 711 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, y, __error1, __error2;
712 function __body(__errorCode, __result) { 712 function __body(__errorCode, __result) {
713 if (__errorCode == 1) { 713 if (__errorCode === 1) {
714 __currentError = __result; 714 __currentError = __result;
715 __goto = __handler; 715 __goto = __handler;
716 } 716 }
717 while (true) 717 while (true)
718 switch (__goto) { 718 switch (__goto) {
719 case 0: 719 case 0:
720 // Function start 720 // Function start
721 __handler = 3; 721 __handler = 3;
722 __goto = c ? 6 : 8; 722 __goto = c ? 6 : 8;
723 break; 723 break;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 print(await(foo(x))); // calls 813 print(await(foo(x))); // calls
814 (await print)(foo(x)); 814 (await print)(foo(x));
815 print(foo(await x)); 815 print(foo(await x));
816 await (print(foo(await x))); 816 await (print(foo(await x)));
817 print(foo(x, await y, z)); 817 print(foo(x, await y, z));
818 } 818 }
819 """, """ 819 """, """
820 function(x, y, j) { 820 function(x, y, j) {
821 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __temp1, __temp2, __temp3; 821 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __temp1, __temp2, __temp3;
822 function __body(__errorCode, __result) { 822 function __body(__errorCode, __result) {
823 if (__errorCode == 1) { 823 if (__errorCode === 1) {
824 __currentError = __result; 824 __currentError = __result;
825 __goto = __handler; 825 __goto = __handler;
826 } 826 }
827 while (true) 827 while (true)
828 switch (__goto) { 828 switch (__goto) {
829 case 0: 829 case 0:
830 // Function start 830 // Function start
831 __temp1 = print; 831 __temp1 = print;
832 __goto = 2; 832 __goto = 2;
833 return thenHelper(foo(x), __body, __completer); 833 return thenHelper(foo(x), __body, __completer);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 default: // defaul case 896 default: // defaul case
897 break lab; // break to label 897 break lab; // break to label
898 } 898 }
899 foo(); 899 foo();
900 } 900 }
901 } 901 }
902 }""", """ 902 }""", """
903 function(x, y, k) { 903 function(x, y, k) {
904 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __returnValue, __temp1; 904 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __returnValue, __temp1;
905 function __body(__errorCode, __result) { 905 function __body(__errorCode, __result) {
906 if (__errorCode == 1) { 906 if (__errorCode === 1) {
907 __currentError = __result; 907 __currentError = __result;
908 __goto = __handler; 908 __goto = __handler;
909 } 909 }
910 while (true) 910 while (true)
911 switch (__goto) { 911 switch (__goto) {
912 case 0: 912 case 0:
913 // Function start 913 // Function start
914 case 3: 914 case 3:
915 // while condition 915 // while condition
916 __goto = 5; 916 __goto = 5;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // return 1009 // return
1010 return thenHelper(__returnValue, 0, __completer, null); 1010 return thenHelper(__returnValue, 0, __completer, null);
1011 case 2: 1011 case 2:
1012 // rethrow 1012 // rethrow
1013 return thenHelper(__currentError, 1, __completer); 1013 return thenHelper(__currentError, 1, __completer);
1014 } 1014 }
1015 } 1015 }
1016 return thenHelper(null, __body, __completer, null); 1016 return thenHelper(null, __body, __completer, null);
1017 }"""); 1017 }""");
1018 } 1018 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js/rewrite_async.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698