OLD | NEW |
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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 return thenHelper(foo(i), __body, __completer); | 590 return thenHelper(foo(i), __body, __completer); |
591 case 10: | 591 case 10: |
592 // returning from await. | 592 // returning from await. |
593 __temp1(__result); | 593 __temp1(__result); |
594 case 4: | 594 case 4: |
595 // for update | 595 // for update |
596 __goto = 11; | 596 __goto = 11; |
597 return thenHelper(foo2(), __body, __completer); | 597 return thenHelper(foo2(), __body, __completer); |
598 case 11: | 598 case 11: |
599 // returning from await. | 599 // returning from await. |
600 i = __result; | 600 i += __result; |
601 // goto for condition | 601 // goto for condition |
602 __goto = 3; | 602 __goto = 3; |
603 break; | 603 break; |
604 case 5: | 604 case 5: |
605 // after for | 605 // after for |
606 case 1: | 606 case 1: |
607 // return | 607 // return |
608 return thenHelper(__returnValue, 0, __completer, null); | 608 return thenHelper(__returnValue, 0, __completer, null); |
609 case 2: | 609 case 2: |
610 // rethrow | 610 // rethrow |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 } | 1052 } |
1053 // implicit return | 1053 // implicit return |
1054 return thenHelper(null, 0, __completer, null); | 1054 return thenHelper(null, 0, __completer, null); |
1055 case 1: | 1055 case 1: |
1056 // rethrow | 1056 // rethrow |
1057 return thenHelper(__currentError, 1, __completer); | 1057 return thenHelper(__currentError, 1, __completer); |
1058 } | 1058 } |
1059 } | 1059 } |
1060 return thenHelper(null, __body, __completer, null); | 1060 return thenHelper(null, __body, __completer, null); |
1061 }"""); | 1061 }"""); |
| 1062 |
| 1063 testTransform(""" |
| 1064 function(m) async { |
| 1065 var exception = 1; |
| 1066 try { |
| 1067 await 42; |
| 1068 throw 42; |
| 1069 } catch (exception) { |
| 1070 exception = await 10; |
| 1071 exception += await 10; |
| 1072 exception++; |
| 1073 exception--; |
| 1074 ++exception; |
| 1075 --exception; |
| 1076 exception += 10; |
| 1077 } |
| 1078 print(exception); |
| 1079 }""", """ |
| 1080 function(m) { |
| 1081 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError,
__next = [], exception, __exception; |
| 1082 function __body(__errorCode, __result) { |
| 1083 if (__errorCode === 1) { |
| 1084 __currentError = __result; |
| 1085 __goto = __handler; |
| 1086 } |
| 1087 while (true) |
| 1088 switch (__goto) { |
| 1089 case 0: |
| 1090 // Function start |
| 1091 exception = 1; |
| 1092 __handler = 3; |
| 1093 __goto = 6; |
| 1094 return thenHelper(42, __body, __completer); |
| 1095 case 6: |
| 1096 // returning from await. |
| 1097 throw 42; |
| 1098 __handler = 1; |
| 1099 // goto after finally |
| 1100 __goto = 5; |
| 1101 break; |
| 1102 case 3: |
| 1103 // catch |
| 1104 __handler = 2; |
| 1105 __exception = __currentError; |
| 1106 __goto = 7; |
| 1107 return thenHelper(10, __body, __completer); |
| 1108 case 7: |
| 1109 // returning from await. |
| 1110 __exception = __result; |
| 1111 __goto = 8; |
| 1112 return thenHelper(10, __body, __completer); |
| 1113 case 8: |
| 1114 // returning from await. |
| 1115 __exception += __result; |
| 1116 __exception++; |
| 1117 __exception--; |
| 1118 ++__exception; |
| 1119 --__exception; |
| 1120 __exception += 10; |
| 1121 // goto after finally |
| 1122 __goto = 5; |
| 1123 break; |
| 1124 case 2: |
| 1125 // uncaught |
| 1126 // goto rethrow |
| 1127 __goto = 1; |
| 1128 break; |
| 1129 case 5: |
| 1130 // after finally |
| 1131 print(exception); |
| 1132 // implicit return |
| 1133 return thenHelper(null, 0, __completer, null); |
| 1134 case 1: |
| 1135 // rethrow |
| 1136 return thenHelper(__currentError, 1, __completer); |
| 1137 } |
| 1138 } |
| 1139 return thenHelper(null, __body, __completer, null); |
| 1140 }"""); |
1062 } | 1141 } |
OLD | NEW |