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

Unified Diff: tests/compiler/dart2js/async_await_js_transform_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 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 side-by-side diff with in-line comments
Download patch
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 f5df58cb8cfaf9fb8f6c85587f1b33a0d0a30677..0a11fbb11920fff8218c28925200501c477ae300 100644
--- a/tests/compiler/dart2js/async_await_js_transform_test.dart
+++ b/tests/compiler/dart2js/async_await_js_transform_test.dart
@@ -20,40 +20,47 @@ void testTransform(String source, String expected, AsyncRewriterBase rewriter) {
}
void testAsyncTransform(String source, String expected) {
- testTransform(source, expected, new AsyncRewriter(
- null, // The diagnostic helper should not be used in these tests.
- null,
- asyncHelper: new VariableUse("thenHelper"),
- newCompleter: new VariableUse("Completer"),
- wrapBody: new VariableUse("_wrapJsFunctionForAsync"),
- safeVariableName: (String name) => "__$name",
- bodyName: new StringBackedName("body")));
+ testTransform(
+ source,
+ expected,
+ new AsyncRewriter(
+ null, // The diagnostic helper should not be used in these tests.
+ null,
+ asyncHelper: new VariableUse("thenHelper"),
+ newCompleter: new VariableUse("Completer"),
+ wrapBody: new VariableUse("_wrapJsFunctionForAsync"),
+ safeVariableName: (String name) => "__$name",
+ bodyName: new StringBackedName("body")));
}
void testSyncStarTransform(String source, String expected) {
- testTransform(source, expected, new SyncStarRewriter(
- null,
- null,
- endOfIteration: new VariableUse("endOfIteration"),
- newIterable: new VariableUse("newIterable"),
- yieldStarExpression: new VariableUse("yieldStar"),
- uncaughtErrorExpression: new VariableUse("uncaughtError"),
- safeVariableName: (String name) => "__$name",
- bodyName: new StringBackedName("body")));
+ testTransform(
+ source,
+ expected,
+ new SyncStarRewriter(null, null,
+ endOfIteration: new VariableUse("endOfIteration"),
+ newIterable: new VariableUse("newIterable"),
+ yieldStarExpression: new VariableUse("yieldStar"),
+ uncaughtErrorExpression: new VariableUse("uncaughtError"),
+ safeVariableName: (String name) => "__$name",
+ bodyName: new StringBackedName("body")));
}
main() {
- testAsyncTransform( /// 01: ok
-r"""function() async {
+ testAsyncTransform(
+
+ /// 01: ok
+ r"""function() async {
var closures = [new A.main_closure()], v0 = await closures, v1 = 0, v2, v3;
if (v1 < 0 || v1 >= v0.length)
H.ioore(v0, v1);
v2 = 4;
v3 = 2;
P.print(v0[v1].call$2(v2, v3));
-}"""
-, /// 01: ok
- r"""function() {
+}""",
+
+ /// 01: ok
+ r"""function() {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, closures, v0, v1, v2, v3;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
if (__errorCode === 1) {
@@ -84,15 +91,18 @@ r"""function() async {
}
});
return thenHelper(null, body, __completer);
-}"""
- ) /// 01: ok
- ;
+}""")
+
+ /// 01: ok
+ ;
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(a) async {
print(this.x); // Ensure `this` is translated in the helper function.
await foo();
-}""", """
+}""",
+ """
function(a) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __self = this;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -119,7 +129,8 @@ function(a) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(b) async {
try {
__outer: while (true) { // Overlapping label name.
@@ -142,7 +153,8 @@ function(a) {
return 3; // Return from finally with no pending finally.
}
return 4;
- }""", """
+ }""",
+ """
function(b) {
var __goto = 0, __completer = new Completer(), __returnValue, __handler = 2, __currentError, __next = [], __helper;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -243,7 +255,8 @@ function(b) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(c) async {
var a, b, c, d, e, f;
a = b++; // post- and preincrements.
@@ -252,7 +265,8 @@ function(c) async {
d = ++(await foo()).a;
e = foo1()[await foo2()]--;
f = --foo1()[await foo2()];
-}""", """
+}""",
+ """
function(c) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, __temp1;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -298,7 +312,8 @@ function(c) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(d2) async {
var a, b, c, d, e, f, g, h; // empty initializer
a = foo1() || await foo2(); // short circuiting operators
@@ -309,7 +324,8 @@ function(c) {
f = await foo1() && foo2();
g = await foo1() && await foo2();
h = foo1() && foo2();
- }""", """
+ }""",
+ """
function(d2) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, g, h, __temp1;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -431,7 +447,8 @@ function(d2) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(x, y) async {
while (true) {
switch(y) { // Switch with no awaits in case key expressions
@@ -446,7 +463,8 @@ function(x, y) async {
foo(); // No default
}
}
-}""", """
+}""",
+ """
function(x, y) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -525,7 +543,8 @@ function(x, y) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(f) async {
do {
var a = await foo();
@@ -535,7 +554,8 @@ function(x, y) {
continue;
} while (await foo());
}
- """, """
+ """,
+ """
function(f) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -586,7 +606,8 @@ function(f) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(g) async {
for (var i = 0; i < await foo1(); i += await foo2()) {
if (foo(i))
@@ -600,7 +621,8 @@ function(g) async {
print(await(foo(i)));
}
}
-""", """
+""",
+ """
function(g) {
var __goto = 0, __completer = new Completer(), __returnValue, __handler = 2, __currentError, i, __temp1;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -676,7 +698,8 @@ function(g) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(a, h) async {
var x = {"a": foo1(), "b": await foo2(), "c": foo3()};
x["a"] = 2; // Different assignments
@@ -685,7 +708,8 @@ function(g) {
x[(await foo1()).a = await foo2()] = 5;
(await foo1())[await foo2()] = await foo3(6);
}
- """, """
+ """,
+ """
function(a, h) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, __temp1, __temp2;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -751,7 +775,8 @@ function(a, h) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(c, i) async {
try {
var x = c ? await foo() : foo(); // conditional
@@ -766,7 +791,8 @@ function(c, i) async {
}
}
}
-""", """
+""",
+ """
function(c, i) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __next = [], x, y, __error, __error1;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -868,7 +894,8 @@ function(c, i) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(x, y, j) async {
print(await(foo(x))); // calls
(await print)(foo(x));
@@ -876,7 +903,8 @@ function(c, i) {
await (print(foo(await x)));
print(foo(x, await y, z));
}
- """, """
+ """,
+ """
function(x, y, j) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __temp1, __temp2, __temp3;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -934,7 +962,8 @@ function(x, y, j) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(x, y, k) async {
while (await(foo())) {
lab: { // labelled statement
@@ -959,7 +988,8 @@ function(x, y, k) async {
foo();
}
}
-}""", """
+}""",
+ """
function(x, y, k) {
var __goto = 0, __completer = new Completer(), __returnValue, __handler = 2, __currentError, __temp1;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -1074,7 +1104,8 @@ function(x, y, k) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(l) async {
switch(await l) {
case 1:
@@ -1087,7 +1118,8 @@ function(x, y, k) {
print(2);
break;
}
- }""", """
+ }""",
+ """
function(l) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -1123,7 +1155,8 @@ function(l) {
return thenHelper(null, body, __completer);
}""");
- testAsyncTransform("""
+ testAsyncTransform(
+ """
function(m) async {
var exception = 1;
try {
@@ -1139,7 +1172,8 @@ function(l) {
exception += 10;
}
print(exception);
- }""", """
+ }""",
+ """
function(m) {
var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __next = [], exception, __exception;
var body = _wrapJsFunctionForAsync(function(__errorCode, __result) {
@@ -1202,12 +1236,14 @@ function(m) {
return thenHelper(null, body, __completer);
}""");
- testSyncStarTransform("""
+ testSyncStarTransform(
+ """
function(a) sync* {
// Ensure that return of a value is treated as first evaluating the value, and
// then returning.
return foo();
-}""", """
+}""",
+ """
function(__a) {
return new newIterable(function() {
var a = __a;
« no previous file with comments | « tests/compiler/dart2js/array_tracing_mirror_test.dart ('k') | tests/compiler/dart2js/async_compiler_input_provider_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698