Skip to content

Commit d3904f5

Browse files
munificentCommit Queue
authored andcommitted
Reformat tests/lib/async/** using 3.8 style.
Change-Id: I6ccbe1494165c2bda142ece13584c4738e3b43e6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425347 Commit-Queue: Lasse Nielsen <[email protected]> Reviewed-by: Lasse Nielsen <[email protected]> Auto-Submit: Bob Nystrom <[email protected]>
1 parent 8a51cb6 commit d3904f5

File tree

137 files changed

+4074
-2696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+4074
-2696
lines changed

tests/lib/async/async_await_sync_completer_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ foo() async {
1717
// install handlers. When the function finishes, it can then synchronously
1818
// propagate the values.
1919
await null;
20-
new Future.microtask(() => 'in microtask')
21-
.then(events.add)
22-
.then(delayedValue.complete);
20+
new Future.microtask(
21+
() => 'in microtask',
22+
).then(events.add).then(delayedValue.complete);
2323
return 'in async function';
2424
}
2525

@@ -28,9 +28,9 @@ bar() async {
2828
// install handlers. When the function finishes, it can then synchronously
2929
// propagate the values.
3030
await null;
31-
new Future<void>.microtask(() => throw 'in microtask error')
32-
.catchError(events.add)
33-
.then(delayedError.complete);
31+
new Future<void>.microtask(
32+
() => throw 'in microtask error',
33+
).catchError(events.add).then(delayedError.complete);
3434
throw 'in async function error';
3535
}
3636

@@ -42,7 +42,7 @@ void main() {
4242
asyncValueFuture,
4343
delayedValue.future,
4444
asyncErrorFuture,
45-
delayedError.future
45+
delayedError.future,
4646
]).then((_) {
4747
// The body completed before nested microtask. So they should appear
4848
// before the delayed functions. In other words, the async function should
@@ -51,7 +51,7 @@ void main() {
5151
"in async function",
5252
"in async function error",
5353
"in microtask",
54-
"in microtask error"
54+
"in microtask error",
5555
], events);
5656
asyncEnd();
5757
});

tests/lib/async/async_await_zones_test.dart

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ increaseDepth() {
9595
}
9696

9797
ZoneCallback<R> registerCallback<R>(
98-
Zone self, ZoneDelegate parent, Zone zone, R f()) {
98+
Zone self,
99+
ZoneDelegate parent,
100+
Zone zone,
101+
R f(),
102+
) {
99103
var oldDepth = depth;
100104
increaseDepth();
101105
return parent.registerCallback(zone, () {
@@ -105,7 +109,11 @@ ZoneCallback<R> registerCallback<R>(
105109
}
106110

107111
ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
108-
Zone self, ZoneDelegate parent, Zone zone, R f(T arg)) {
112+
Zone self,
113+
ZoneDelegate parent,
114+
Zone zone,
115+
R f(T arg),
116+
) {
109117
var oldDepth = depth;
110118
increaseDepth();
111119
return parent.registerUnaryCallback(zone, (x) {
@@ -115,7 +123,11 @@ ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
115123
}
116124

117125
ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
118-
Zone self, ZoneDelegate parent, Zone zone, R f(T1 arg1, T2 arg2)) {
126+
Zone self,
127+
ZoneDelegate parent,
128+
Zone zone,
129+
R f(T1 arg1, T2 arg2),
130+
) {
119131
var oldDepth = depth;
120132
increaseDepth();
121133
return parent.registerBinaryCallback(zone, (x, y) {
@@ -136,10 +148,11 @@ void sm(Zone self, ZoneDelegate parent, Zone zone, f) {
136148
main() {
137149
asyncStart();
138150
var desc = new ZoneSpecification(
139-
registerCallback: registerCallback,
140-
registerUnaryCallback: registerUnaryCallback,
141-
registerBinaryCallback: registerBinaryCallback,
142-
scheduleMicrotask: sm);
151+
registerCallback: registerCallback,
152+
registerUnaryCallback: registerUnaryCallback,
153+
registerBinaryCallback: registerBinaryCallback,
154+
scheduleMicrotask: sm,
155+
);
143156
var future = runZoned(runTests, zoneSpecification: desc);
144157
future.then((_) => asyncEnd());
145158
}

tests/lib/async/async_no_await_zones_test.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ var log = [];
1111

1212
main() {
1313
asyncStart();
14-
runZoned(() {
15-
dynamic d = new AsyncDoEvent();
16-
return d.doEvent();
17-
}, zoneSpecification: new ZoneSpecification(
18-
scheduleMicrotask: (self, parent, zone, fn) {
19-
log.add('scheduleMicrotask()');
20-
return parent.scheduleMicrotask(zone, fn);
14+
runZoned(
15+
() {
16+
dynamic d = new AsyncDoEvent();
17+
return d.doEvent();
2118
},
22-
)).then((_) {
19+
zoneSpecification: new ZoneSpecification(
20+
scheduleMicrotask: (self, parent, zone, fn) {
21+
log.add('scheduleMicrotask()');
22+
return parent.scheduleMicrotask(zone, fn);
23+
},
24+
),
25+
).then((_) {
2326
Expect.listEquals(log, ['doEvent()', 'scheduleMicrotask()']);
2427
asyncEnd();
2528
});

tests/lib/async/catch_errors.dart

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,37 @@ Stream catchErrors(dynamic body()) {
2222
return controller.stream;
2323
}
2424

25-
runZonedScheduleMicrotask(body(),
26-
{void onScheduleMicrotask(void callback())?, Function? onError}) {
25+
runZonedScheduleMicrotask(
26+
body(), {
27+
void onScheduleMicrotask(void callback())?,
28+
Function? onError,
29+
}) {
2730
if (onScheduleMicrotask == null) {
2831
return runZonedGuarded(body, onError as void Function(Object, StackTrace));
2932
}
3033
HandleUncaughtErrorHandler? errorHandler;
3134
if (onError != null) {
32-
errorHandler = (Zone self, ZoneDelegate parent, Zone zone, error,
33-
StackTrace stackTrace) {
34-
try {
35-
return self.parent!.runUnary(onError as void Function(Object), error);
36-
} catch (e, s) {
37-
if (identical(e, error)) {
38-
return parent.handleUncaughtError(zone, error, stackTrace);
39-
} else {
40-
return parent.handleUncaughtError(zone, e, s);
41-
}
42-
}
43-
};
35+
errorHandler =
36+
(
37+
Zone self,
38+
ZoneDelegate parent,
39+
Zone zone,
40+
error,
41+
StackTrace stackTrace,
42+
) {
43+
try {
44+
return self.parent!.runUnary(
45+
onError as void Function(Object),
46+
error,
47+
);
48+
} catch (e, s) {
49+
if (identical(e, error)) {
50+
return parent.handleUncaughtError(zone, error, stackTrace);
51+
} else {
52+
return parent.handleUncaughtError(zone, e, s);
53+
}
54+
}
55+
};
4456
}
4557
ScheduleMicrotaskHandler? asyncHandler;
4658
if (onScheduleMicrotask != null) {
@@ -49,7 +61,9 @@ runZonedScheduleMicrotask(body(),
4961
};
5062
}
5163
ZoneSpecification specification = new ZoneSpecification(
52-
handleUncaughtError: errorHandler, scheduleMicrotask: asyncHandler);
64+
handleUncaughtError: errorHandler,
65+
scheduleMicrotask: asyncHandler,
66+
);
5367
Zone zone = Zone.current.fork(specification: specification);
5468
if (onError != null) {
5569
return zone.runGuarded(body);

tests/lib/async/catch_errors11_test.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ main() {
2222
done.complete(true);
2323
throw "timer error";
2424
});
25-
}).listen((x) {
26-
events.add(x);
27-
}, onDone: () {
28-
Expect.fail("Unexpected callback");
29-
});
25+
}).listen(
26+
(x) {
27+
events.add(x);
28+
},
29+
onDone: () {
30+
Expect.fail("Unexpected callback");
31+
},
32+
);
3033

3134
done.future.whenComplete(() {
3235
// Give the handler time to execute.

tests/lib/async/catch_errors12_test.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ main() {
3131
});
3232
});
3333
throw "catch error";
34-
}).listen((x) {
35-
events.add(x);
36-
}, onDone: () {
37-
Expect.fail("Unexpected callback");
38-
});
34+
}).listen(
35+
(x) {
36+
events.add(x);
37+
},
38+
onDone: () {
39+
Expect.fail("Unexpected callback");
40+
},
41+
);
3942
done.future.whenComplete(() {
4043
// Give time to execute the callbacks.
4144
Timer.run(() {

tests/lib/async/catch_errors13_test.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ main() {
6666
throw "timer outer";
6767
});
6868
throw "inner throw";
69-
}).listen((x) {
70-
events.add(x);
71-
if (x == "inner done throw") done.complete(true);
72-
}, onDone: () {
73-
Expect.fail("Unexpected callback");
74-
});
69+
}).listen(
70+
(x) {
71+
events.add(x);
72+
if (x == "inner done throw") done.complete(true);
73+
},
74+
onDone: () {
75+
Expect.fail("Unexpected callback");
76+
},
77+
);
7578

7679
done.future.whenComplete(() {
7780
// Give callbacks time to run.
@@ -86,7 +89,7 @@ main() {
8689
"timer outer",
8790
"delayed error",
8891
"scheduleMicrotask",
89-
"inner done throw"
92+
"inner done throw",
9093
], events);
9194
asyncEnd();
9295
});

tests/lib/async/catch_errors14_test.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ main() {
2424
}
2525
throw "error $counter";
2626
});
27-
}).listen((x) {
28-
events.add(x);
29-
}, onDone: () {
30-
Expect.fail("Unexpected callback");
31-
});
27+
}).listen(
28+
(x) {
29+
events.add(x);
30+
},
31+
onDone: () {
32+
Expect.fail("Unexpected callback");
33+
},
34+
);
3235

3336
done.future.whenComplete(() {
3437
// Give time to complete the handlers.

tests/lib/async/catch_errors15_test.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,25 @@ main() {
2525
throw "delayed error";
2626
});
2727
throw "catch error";
28-
}).listen((x) {
29-
events.add("i $x");
30-
if (x == "delayed error") done.complete(true);
31-
}, onDone: () {
32-
Expect.fail("Unexpected callback");
33-
});
28+
}).listen(
29+
(x) {
30+
events.add("i $x");
31+
if (x == "delayed error") done.complete(true);
32+
},
33+
onDone: () {
34+
Expect.fail("Unexpected callback");
35+
},
36+
);
3437
events.add("after inner");
3538
throw "inner throw";
36-
}).listen((x) {
37-
events.add("o $x");
38-
}, onDone: () {
39-
Expect.fail("Unexpected callback");
40-
});
39+
}).listen(
40+
(x) {
41+
events.add("o $x");
42+
},
43+
onDone: () {
44+
Expect.fail("Unexpected callback");
45+
},
46+
);
4147
done.future.whenComplete(() {
4248
// Give some time to run the handlers.
4349
Timer.run(() {

tests/lib/async/catch_errors16_test.dart

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ main() {
2323
events.add(x);
2424
});
2525
stream
26-
.transform(new StreamTransformer.fromHandlers(handleError: (e, st, sink) {
27-
sink.add("error $e");
28-
})).listen((x) {
29-
events.add("stream $x");
30-
}, onDone: () {
31-
Expect.listEquals([
32-
"stream 101",
33-
"stream error 2",
34-
], events);
35-
asyncEnd();
36-
});
26+
.transform(
27+
new StreamTransformer.fromHandlers(
28+
handleError: (e, st, sink) {
29+
sink.add("error $e");
30+
},
31+
),
32+
)
33+
.listen(
34+
(x) {
35+
events.add("stream $x");
36+
},
37+
onDone: () {
38+
Expect.listEquals(["stream 101", "stream error 2"], events);
39+
asyncEnd();
40+
},
41+
);
3742
controller.add(1);
3843
controller.addError(2);
3944
controller.close();

0 commit comments

Comments
 (0)