Skip to content

Commit e5a4028

Browse files
authored
Dartfmt lib/src/**/*.dart and test/**/*.dart (#577)
Dartfmt *.dart
1 parent 56a87b1 commit e5a4028

File tree

131 files changed

+4345
-3362
lines changed

Some content is hidden

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

131 files changed

+4345
-3362
lines changed

lib/pub_serve.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class PubServeTransformer extends Transformer implements DeclaringTransformer {
2727
Future apply(Transform transform) async {
2828
var id = transform.primaryInput.id;
2929

30-
transform.addOutput(
31-
new Asset.fromString(id.addExtension('.vm_test.dart'), '''
30+
transform.addOutput(new Asset.fromString(
31+
id.addExtension('.vm_test.dart'),
32+
'''
3233
import "dart:isolate";
3334
3435
import "package:stream_channel/stream_channel.dart";
@@ -47,8 +48,9 @@ class PubServeTransformer extends Transformer implements DeclaringTransformer {
4748
}
4849
'''));
4950

50-
transform.addOutput(
51-
new Asset.fromString(id.addExtension('.browser_test.dart'), '''
51+
transform.addOutput(new Asset.fromString(
52+
id.addExtension('.browser_test.dart'),
53+
'''
5254
import "package:stream_channel/stream_channel.dart";
5355
5456
import "package:test/src/runner/plugin/remote_platform_helpers.dart";
@@ -67,8 +69,9 @@ class PubServeTransformer extends Transformer implements DeclaringTransformer {
6769
var htmlId = id.changeExtension('.html');
6870
if (await transform.hasInput(htmlId)) return;
6971

70-
transform.addOutput(
71-
new Asset.fromString(htmlId, '''
72+
transform.addOutput(new Asset.fromString(
73+
htmlId,
74+
'''
7275
<!DOCTYPE html>
7376
<html>
7477
<head>

lib/src/backend/declarer.dart

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,19 @@ class Declarer {
9696
declare(body()) => runZoned(body, zoneValues: {#test.declarer: this});
9797

9898
/// Defines a test case with the given name and body.
99-
void test(String name, body(), {String testOn, Timeout timeout, skip,
100-
Map<String, dynamic> onPlatform, tags}) {
99+
void test(String name, body(),
100+
{String testOn,
101+
Timeout timeout,
102+
skip,
103+
Map<String, dynamic> onPlatform,
104+
tags}) {
101105
_checkNotBuilt("test");
102106

103107
var metadata = _metadata.merge(new Metadata.parse(
104-
testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform,
108+
testOn: testOn,
109+
timeout: timeout,
110+
skip: skip,
111+
onPlatform: onPlatform,
105112
tags: tags));
106113

107114
_entries.add(new LocalTest(_prefix(name), metadata, () async {
@@ -127,17 +134,24 @@ class Declarer {
127134
}
128135

129136
/// Creates a group of tests.
130-
void group(String name, void body(), {String testOn, Timeout timeout, skip,
131-
Map<String, dynamic> onPlatform, tags}) {
137+
void group(String name, void body(),
138+
{String testOn,
139+
Timeout timeout,
140+
skip,
141+
Map<String, dynamic> onPlatform,
142+
tags}) {
132143
_checkNotBuilt("group");
133144

134145
var metadata = _metadata.merge(new Metadata.parse(
135-
testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform,
146+
testOn: testOn,
147+
timeout: timeout,
148+
skip: skip,
149+
onPlatform: onPlatform,
136150
tags: tags));
137151
var trace = _collectTraces ? new Trace.current(2) : null;
138152

139-
var declarer = new Declarer._(
140-
this, _prefix(name), metadata, _collectTraces, trace);
153+
var declarer =
154+
new Declarer._(this, _prefix(name), metadata, _collectTraces, trace);
141155
declarer.declare(() {
142156
// Cast to dynamic to avoid the analyzer complaining about us using the
143157
// result of a void method.

lib/src/backend/group.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ class Group implements GroupEntry {
4040
/// The number of tests (recursively) in this group.
4141
int get testCount {
4242
if (_testCount != null) return _testCount;
43-
_testCount = entries.fold(0,
44-
(count, entry) => count + (entry is Group ? entry.testCount : 1));
43+
_testCount = entries.fold(
44+
0, (count, entry) => count + (entry is Group ? entry.testCount : 1));
4545
return _testCount;
4646
}
47+
4748
int _testCount;
4849

49-
Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata,
50-
this.trace, Test this.setUpAll, Test this.tearDownAll})
50+
Group(this.name, Iterable<GroupEntry> entries,
51+
{Metadata metadata,
52+
this.trace,
53+
Test this.setUpAll,
54+
Test this.tearDownAll})
5155
: entries = new List<GroupEntry>.unmodifiable(entries),
5256
metadata = metadata == null ? new Metadata() : metadata;
5357

lib/src/backend/invoker.dart

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class LocalTest extends Test {
3131
/// The test body.
3232
final AsyncFunction _body;
3333

34-
LocalTest(this.name, this.metadata, body(), {this.trace})
35-
: _body = body;
34+
LocalTest(this.name, this.metadata, body(), {this.trace}) : _body = body;
3635

3736
/// Loads a single runnable instance of this test.
3837
LiveTest load(Suite suite, {Iterable<Group> groups}) {
@@ -135,7 +134,8 @@ class Invoker {
135134

136135
Invoker._(Suite suite, LocalTest test, {Iterable<Group> groups}) {
137136
_controller = new LiveTestController(
138-
suite, test, _onRun, _onCloseCompleter.complete, groups: groups);
137+
suite, test, _onRun, _onCloseCompleter.complete,
138+
groups: groups);
139139
}
140140

141141
/// Runs [callback] after this test completes.
@@ -204,9 +204,7 @@ class Invoker {
204204
await fn();
205205
counter.removeOutstandingCallback();
206206
}, onError: _handleError);
207-
}, zoneValues: {
208-
_counterKey: counter
209-
});
207+
}, zoneValues: {_counterKey: counter});
210208

211209
return counter.noOutstandingCallbacks.whenComplete(() {
212210
_outstandingCallbackZones.remove(zone);
@@ -221,9 +219,7 @@ class Invoker {
221219
unclosable(fn()) {
222220
heartbeat();
223221

224-
return runZoned(fn, zoneValues: {
225-
_closableKey: false
226-
});
222+
return runZoned(fn, zoneValues: {_closableKey: false});
227223
}
228224

229225
/// Notifies the invoker that progress is being made.
@@ -234,15 +230,14 @@ class Invoker {
234230
if (liveTest.isComplete) return;
235231
if (_timeoutTimer != null) _timeoutTimer.cancel();
236232

237-
var timeout = liveTest.test.metadata.timeout
238-
.apply(new Duration(seconds: 30));
233+
var timeout =
234+
liveTest.test.metadata.timeout.apply(new Duration(seconds: 30));
239235
if (timeout == null) return;
240236
_timeoutTimer = _invokerZone.createTimer(timeout, () {
241237
_outstandingCallbackZones.last.run(() {
242238
if (liveTest.isComplete) return;
243-
_handleError(
244-
new TimeoutException(
245-
"Test timed out after ${niceDuration(timeout)}.", timeout));
239+
_handleError(new TimeoutException(
240+
"Test timed out after ${niceDuration(timeout)}.", timeout));
246241
});
247242
});
248243
}
@@ -259,8 +254,8 @@ class Invoker {
259254
// failing after being complete.
260255
_controller.setState(const State(Status.complete, Result.error));
261256
throw "This test was marked as skipped after it had already completed. "
262-
"Make sure to use\n"
263-
"[expectAsync] or the [completes] matcher when testing async code.";
257+
"Make sure to use\n"
258+
"[expectAsync] or the [completes] matcher when testing async code.";
264259
}
265260

266261
if (message != null) _controller.message(new Message.skip(message));
@@ -312,7 +307,7 @@ class Invoker {
312307

313308
_handleError(
314309
"This test failed after it had already completed. Make sure to use "
315-
"[expectAsync]\n"
310+
"[expectAsync]\n"
316311
"or the [completes] matcher when testing async code.",
317312
stackTrace);
318313
}
@@ -339,25 +334,25 @@ class Invoker {
339334
// microtask-level events.
340335
new Future(() async {
341336
await _test._body();
342-
await unclosable(() =>
343-
Future.forEach(_tearDowns.reversed, errorsDontStopTest));
337+
await unclosable(
338+
() => Future.forEach(_tearDowns.reversed, errorsDontStopTest));
344339
removeOutstandingCallback();
345340
});
346341

347342
await _outstandingCallbacks.noOutstandingCallbacks;
348343
if (_timeoutTimer != null) _timeoutTimer.cancel();
349344

350-
_controller.setState(
351-
new State(Status.complete, liveTest.state.result));
345+
_controller.setState(new State(Status.complete, liveTest.state.result));
352346

353347
_controller.completer.complete();
354-
}, zoneValues: {
355-
#test.invoker: this,
356-
// Use the invoker as a key so that multiple invokers can have different
357-
// outstanding callback counters at once.
358-
_counterKey: outstandingCallbacksForBody,
359-
_closableKey: true
360348
},
349+
zoneValues: {
350+
#test.invoker: this,
351+
// Use the invoker as a key so that multiple invokers can have different
352+
// outstanding callback counters at once.
353+
_counterKey: outstandingCallbacksForBody,
354+
_closableKey: true
355+
},
361356
zoneSpecification: new ZoneSpecification(
362357
print: (self, parent, zone, line) =>
363358
_controller.message(new Message.print(line))),

lib/src/backend/live_test_controller.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ class LiveTestController {
8585
///
8686
/// This is synchronous to ensure that events are well-ordered across multiple
8787
/// streams.
88-
final _onStateChangeController = new StreamController<State>
89-
.broadcast(sync: true);
88+
final _onStateChangeController =
89+
new StreamController<State>.broadcast(sync: true);
9090

9191
/// The controller for [LiveTest.onError].
9292
///
9393
/// This is synchronous to ensure that events are well-ordered across multiple
9494
/// streams.
95-
final _onErrorController = new StreamController<AsyncError>
96-
.broadcast(sync: true);
95+
final _onErrorController =
96+
new StreamController<AsyncError>.broadcast(sync: true);
9797

9898
/// The controller for [LiveTest.onMessage].
9999
///
@@ -128,13 +128,12 @@ class LiveTestController {
128128
/// If [groups] is passed, it's used to populate the list of groups that
129129
/// contain this test. Otherwise, `suite.group` is used.
130130
LiveTestController(Suite suite, this._test, void onRun(), void onClose(),
131-
{Iterable<Group> groups})
131+
{Iterable<Group> groups})
132132
: _suite = suite,
133133
_onRun = onRun,
134134
_onClose = onClose,
135-
_groups = groups == null
136-
? [suite.group]
137-
: new List.unmodifiable(groups) {
135+
_groups =
136+
groups == null ? [suite.group] : new List.unmodifiable(groups) {
138137
_liveTest = new _LiveTest(this);
139138
}
140139

lib/src/backend/message.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ class MessageType {
3030

3131
factory MessageType.parse(String name) {
3232
switch (name) {
33-
case "print": return MessageType.print;
34-
case "skip": return MessageType.skip;
35-
default: throw new ArgumentError('Invalid message type "$name".');
33+
case "print":
34+
return MessageType.print;
35+
case "skip":
36+
return MessageType.skip;
37+
default:
38+
throw new ArgumentError('Invalid message type "$name".');
3639
}
3740
}
3841

0 commit comments

Comments
 (0)