Index: tests/compiler/dart2js/async_await_js_transform_test.dart |
diff --git a/tests/compiler/dart2js/async_await_js_transform_test.dart b/tests/compiler/dart2js/async_await_js_transform_test.dart |
index 43249a3137885c08d938ba4c109adabafba3382a..b84700a27d10b07c2d3987dfa2ee5630b1c2bfe9 100644 |
--- a/tests/compiler/dart2js/async_await_js_transform_test.dart |
+++ b/tests/compiler/dart2js/async_await_js_transform_test.dart |
@@ -26,7 +26,10 @@ void testAsyncTransform(String source, String expected) { |
new AsyncRewriter( |
null, // The diagnostic helper should not be used in these tests. |
null, |
- asyncHelper: new VariableUse("thenHelper"), |
+ asyncStart: new VariableUse("startHelper"), |
+ asyncAwait: new VariableUse("awaitHelper"), |
+ asyncReturn: new VariableUse("returnHelper"), |
+ asyncRethrow: new VariableUse("rethrowHelper"), |
completerFactory: new VariableUse("NewCompleter"), |
wrapBody: new VariableUse("_wrapJsFunctionForAsync"), |
safeVariableName: (String name) => "__$name", |
@@ -73,7 +76,7 @@ main() { |
// Function start |
closures = [new A.main_closure()]; |
__goto = 2; |
- return thenHelper(closures, body, __completer); |
+ return awaitHelper(closures, body); |
case 2: |
// returning from await. |
v0 = __result; |
@@ -84,13 +87,13 @@ main() { |
v3 = 2; |
P.print(v0[v1].call$2(v2, v3)); |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}""") |
/// 01: ok |
@@ -116,17 +119,17 @@ function(a) { |
// Function start |
print(__self.x); |
__goto = 2; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 2: |
// returning from await. |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -186,7 +189,7 @@ function(b) { |
break __outer1; |
} |
__goto = 12; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 12: |
// returning from await. |
__helper = __result; |
@@ -246,13 +249,13 @@ function(b) { |
break; |
case 1: |
// return |
- return thenHelper(__returnValue, 0, __completer); |
+ return returnHelper(__returnValue, __completer); |
case 2: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -281,35 +284,35 @@ function(c) { |
a = b++; |
b = --b; |
__goto = 2; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 2: |
// returning from await. |
c = __result.a++; |
__goto = 3; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 3: |
// returning from await. |
d = ++__result.a; |
__temp1 = foo1(); |
__goto = 4; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 4: |
// returning from await. |
e = __temp1[__result]--; |
__temp1 = foo1(); |
__goto = 5; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 5: |
// returning from await. |
f = --__temp1[__result]; |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -351,19 +354,19 @@ function(d2) { |
case 2: |
// then |
__goto = 4; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 4: |
// returning from await. |
case 3: |
// join |
a = __result; |
__goto = 5; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 5: |
// returning from await. |
b = __result || foo2(); |
__goto = 8; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 8: |
// returning from await. |
__temp1 = __result; |
@@ -381,7 +384,7 @@ function(d2) { |
// then |
__temp1 = foo3; |
__goto = 9; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 9: |
// returning from await. |
__result = __temp1(__result); |
@@ -402,19 +405,19 @@ function(d2) { |
case 10: |
// then |
__goto = 12; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 12: |
// returning from await. |
case 11: |
// join |
e = __result; |
__goto = 13; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 13: |
// returning from await. |
f = __result && foo2(); |
__goto = 16; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 16: |
// returning from await. |
__temp1 = __result; |
@@ -430,7 +433,7 @@ function(d2) { |
case 14: |
// then |
__goto = 17; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 17: |
// returning from await. |
case 15: |
@@ -438,13 +441,13 @@ function(d2) { |
g = __result; |
h = foo1() && foo2(); |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -508,7 +511,7 @@ function(x, y) { |
case 7: |
// case |
__goto = 10; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 10: |
// returning from await. |
// goto while condition |
@@ -517,7 +520,7 @@ function(x, y) { |
case 8: |
// case |
__goto = 11; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 11: |
// returning from await. |
// goto after switch |
@@ -534,13 +537,13 @@ function(x, y) { |
case 3: |
// after while |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -570,7 +573,7 @@ function(f) { |
case 2: |
// do body |
__goto = 5; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 5: |
// returning from await. |
a = __result; |
@@ -586,7 +589,7 @@ function(f) { |
case 3: |
// do condition |
__goto = 6; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 6: |
// returning from await. |
if (__result) { |
@@ -597,13 +600,13 @@ function(f) { |
case 4: |
// after do |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -639,7 +642,7 @@ function(g) { |
// for condition |
__temp1 = i; |
__goto = 6; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 6: |
// returning from await. |
if (!(__temp1 < __result)) { |
@@ -661,7 +664,7 @@ function(g) { |
case 7: |
// then |
__goto = 9; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 9: |
// returning from await. |
// goto return |
@@ -671,14 +674,14 @@ function(g) { |
// join |
__temp1 = print; |
__goto = 10; |
- return thenHelper(foo(i), body, __completer); |
+ return awaitHelper(foo(i), body); |
case 10: |
// returning from await. |
__temp1(__result); |
case 4: |
// for update |
__goto = 11; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 11: |
// returning from await. |
i += __result; |
@@ -689,13 +692,13 @@ function(g) { |
// after for |
case 1: |
// return |
- return thenHelper(__returnValue, 0, __completer); |
+ return returnHelper(__returnValue, __completer); |
case 2: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -723,56 +726,56 @@ function(a, h) { |
// Function start |
__temp1 = foo1(); |
__goto = 2; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 2: |
// returning from await. |
x = {a: __temp1, b: __result, c: foo3()}; |
x.a = 2; |
__goto = 3; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 3: |
// returning from await. |
__result.a = 3; |
__temp1 = x; |
__goto = 4; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 4: |
// returning from await. |
__temp1[__result] = 4; |
__temp1 = x; |
__goto = 5; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 5: |
// returning from await. |
__temp2 = __result; |
__goto = 6; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 6: |
// returning from await. |
__temp1[__temp2.a = __result] = 5; |
__goto = 7; |
- return thenHelper(foo1(), body, __completer); |
+ return awaitHelper(foo1(), body); |
case 7: |
// returning from await. |
__temp1 = __result; |
__goto = 8; |
- return thenHelper(foo2(), body, __completer); |
+ return awaitHelper(foo2(), body); |
case 8: |
// returning from await. |
__temp2 = __result; |
__goto = 9; |
- return thenHelper(foo3(6), body, __completer); |
+ return awaitHelper(foo3(6), body); |
case 9: |
// returning from await. |
__temp1[__temp2] = __result; |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -810,7 +813,7 @@ function(c, i) { |
case 6: |
// then |
__goto = 9; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 9: |
// returning from await. |
// goto join |
@@ -837,7 +840,7 @@ function(c, i) { |
case 14: |
// then |
__goto = 17; |
- return thenHelper(fooError(__error), body, __completer); |
+ return awaitHelper(fooError(__error), body); |
case 17: |
// returning from await. |
// goto join |
@@ -885,13 +888,13 @@ function(c, i) { |
case 5: |
// after finally |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -918,48 +921,48 @@ function(x, y, j) { |
// Function start |
__temp1 = print; |
__goto = 2; |
- return thenHelper(foo(x), body, __completer); |
+ return awaitHelper(foo(x), body); |
case 2: |
// returning from await. |
__temp1(__result); |
__goto = 3; |
- return thenHelper(print, body, __completer); |
+ return awaitHelper(print, body); |
case 3: |
// returning from await. |
__result(foo(x)); |
__temp1 = print; |
__temp2 = foo; |
__goto = 4; |
- return thenHelper(x, body, __completer); |
+ return awaitHelper(x, body); |
case 4: |
// returning from await. |
__temp1(__temp2(__result)); |
__temp1 = print; |
__temp2 = foo; |
__goto = 6; |
- return thenHelper(x, body, __completer); |
+ return awaitHelper(x, body); |
case 6: |
// returning from await. |
__goto = 5; |
- return thenHelper(__temp1(__temp2(__result)), body, __completer); |
+ return awaitHelper(__temp1(__temp2(__result)), body); |
case 5: |
// returning from await. |
__temp1 = print; |
__temp2 = foo; |
__temp3 = x; |
__goto = 7; |
- return thenHelper(y, body, __completer); |
+ return awaitHelper(y, body); |
case 7: |
// returning from await. |
__temp1(__temp2(__temp3, __result, z)); |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -1004,7 +1007,7 @@ function(x, y, k) { |
case 3: |
// while condition |
__goto = 5; |
- return thenHelper(foo(), body, __completer); |
+ return awaitHelper(foo(), body); |
case 5: |
// returning from await. |
if (!__result) { |
@@ -1026,7 +1029,7 @@ function(x, y, k) { |
break; |
} |
__goto = 12; |
- return thenHelper(bar(), body, __completer); |
+ return awaitHelper(bar(), body); |
case 12: |
// returning from await. |
if (__temp1 === __result) { |
@@ -1049,7 +1052,7 @@ function(x, y, k) { |
// case |
__temp1 = print; |
__goto = 15; |
- return thenHelper(foo1(x), body, __completer); |
+ return awaitHelper(foo1(x), body); |
case 15: |
// returning from await. |
__temp1(__result); |
@@ -1061,7 +1064,7 @@ function(x, y, k) { |
// case |
__temp1 = print; |
__goto = 16; |
- return thenHelper(foobar(x), body, __completer); |
+ return awaitHelper(foobar(x), body); |
case 16: |
// returning from await. |
__temp1(__result); |
@@ -1095,13 +1098,13 @@ function(x, y, k) { |
// after while |
case 1: |
// return |
- return thenHelper(__returnValue, 0, __completer); |
+ return returnHelper(__returnValue, __completer); |
case 2: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -1132,7 +1135,7 @@ function(l) { |
case 0: |
// Function start |
__goto = 2; |
- return thenHelper(l, body, __completer); |
+ return awaitHelper(l, body); |
case 2: |
// returning from await. |
switch (__result) { |
@@ -1146,13 +1149,13 @@ function(l) { |
break; |
} |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testAsyncTransform( |
@@ -1188,7 +1191,7 @@ function(m) { |
exception = 1; |
__handler = 3; |
__goto = 6; |
- return thenHelper(42, body, __completer); |
+ return awaitHelper(42, body); |
case 6: |
// returning from await. |
throw 42; |
@@ -1201,12 +1204,12 @@ function(m) { |
__handler = 2; |
__exception = __currentError; |
__goto = 7; |
- return thenHelper(10, body, __completer); |
+ return awaitHelper(10, body); |
case 7: |
// returning from await. |
__exception = __result; |
__goto = 8; |
- return thenHelper(10, body, __completer); |
+ return awaitHelper(10, body); |
case 8: |
// returning from await. |
__exception += __result; |
@@ -1227,13 +1230,13 @@ function(m) { |
// after finally |
print(exception); |
// implicit return |
- return thenHelper(null, 0, __completer); |
+ return returnHelper(null, __completer); |
case 1: |
// rethrow |
- return thenHelper(__currentError, 1, __completer); |
+ return rethrowHelper(__currentError, __completer); |
} |
}); |
- return thenHelper(null, body, __completer); |
+ return startHelper(body, __completer); |
}"""); |
testSyncStarTransform( |