Skip to content

Commit 65a3769

Browse files
authored
Use latest analyzer and language version (#2523)
- Migrate to the new `name` field definition. - Require the latest `analyzer`. - Update min SDK to one supported by analyer. - Reformat at the latest language version. - Use single underscore wildcards.
1 parent c201cc9 commit 65a3769

File tree

257 files changed

+16937
-11693
lines changed

Some content is hidden

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

257 files changed

+16937
-11693
lines changed

.github/workflows/dart.yml

Lines changed: 113 additions & 113 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: regression_tests
22
publish_to: none
33
environment:
4-
sdk: ^3.5.0
4+
sdk: ^3.7.0
55
resolution: workspace
66
dependencies:
77
test: any

integration_tests/spawn_hybrid/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: spawn_hybrid
22
publish_to: none
33
environment:
4-
sdk: ^3.5.0
4+
sdk: ^3.7.0
55
resolution: workspace
66
dependencies:
77
async: ^2.9.0

integration_tests/spawn_hybrid/test/hybrid_test.dart

Lines changed: 143 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,46 @@ import 'package:test/test.dart';
1111

1212
void main() {
1313
group('spawnHybridUri():', () {
14-
test('loads a file in a separate isolate connected via StreamChannel',
15-
() async {
16-
expect(spawnHybridUri('util/emits_numbers.dart').stream.toList(),
17-
completion(equals([1, 2, 3])));
18-
});
14+
test(
15+
'loads a file in a separate isolate connected via StreamChannel',
16+
() async {
17+
expect(
18+
spawnHybridUri('util/emits_numbers.dart').stream.toList(),
19+
completion(equals([1, 2, 3])),
20+
);
21+
},
22+
);
1923

2024
test('resolves root-relative URIs relative to the package root', () async {
21-
expect(spawnHybridUri('/test/util/emits_numbers.dart').stream.toList(),
22-
completion(equals([1, 2, 3])));
25+
expect(
26+
spawnHybridUri('/test/util/emits_numbers.dart').stream.toList(),
27+
completion(equals([1, 2, 3])),
28+
);
2329
});
2430

2531
test('supports Uri objects', () async {
2632
expect(
27-
spawnHybridUri(Uri.parse('util/emits_numbers.dart')).stream.toList(),
28-
completion(equals([1, 2, 3])));
33+
spawnHybridUri(Uri.parse('util/emits_numbers.dart')).stream.toList(),
34+
completion(equals([1, 2, 3])),
35+
);
2936
});
3037

3138
test('supports package: uris referencing the root package', () async {
3239
expect(
33-
spawnHybridUri(Uri.parse('package:spawn_hybrid/emits_numbers.dart'))
34-
.stream
35-
.toList(),
36-
completion(equals([1, 2, 3])));
40+
spawnHybridUri(
41+
Uri.parse('package:spawn_hybrid/emits_numbers.dart'),
42+
).stream.toList(),
43+
completion(equals([1, 2, 3])),
44+
);
3745
});
3846

3947
test('supports package: uris referencing dependency packages', () async {
4048
expect(
41-
spawnHybridUri(Uri.parse('package:other_package/emits_numbers.dart'))
42-
.stream
43-
.toList(),
44-
completion(equals([1, 2, 3])));
49+
spawnHybridUri(
50+
Uri.parse('package:other_package/emits_numbers.dart'),
51+
).stream.toList(),
52+
completion(equals([1, 2, 3])),
53+
);
4554
});
4655

4756
test('rejects non-String, non-Uri objects', () {
@@ -50,65 +59,83 @@ void main() {
5059

5160
test('passes a message to the hybrid isolate', () async {
5261
expect(
53-
spawnHybridUri('util/echos_message.dart', message: 123).stream.first,
54-
completion(equals(123)));
62+
spawnHybridUri('util/echos_message.dart', message: 123).stream.first,
63+
completion(equals(123)),
64+
);
5565
expect(
56-
spawnHybridUri('util/echos_message.dart', message: 'wow')
57-
.stream
58-
.first,
59-
completion(equals('wow')));
66+
spawnHybridUri('util/echos_message.dart', message: 'wow').stream.first,
67+
completion(equals('wow')),
68+
);
6069
});
6170

62-
test('emits an error from the stream channel if the isolate fails to load',
63-
() {
64-
expect(spawnHybridUri('non existent file').stream.first,
65-
throwsA(isA<Exception>()));
66-
});
71+
test(
72+
'emits an error from the stream channel if the isolate fails to load',
73+
() {
74+
expect(
75+
spawnHybridUri('non existent file').stream.first,
76+
throwsA(isA<Exception>()),
77+
);
78+
},
79+
);
6780
});
6881

6982
group('spawnHybridCode()', () {
70-
test('loads the code in a separate isolate connected via StreamChannel',
71-
() {
72-
expect(spawnHybridCode('''
83+
test(
84+
'loads the code in a separate isolate connected via StreamChannel',
85+
() {
86+
expect(
87+
spawnHybridCode('''
7388
import "package:stream_channel/stream_channel.dart";
7489
7590
void hybridMain(StreamChannel channel) {
7691
channel.sink..add(1)..add(2)..add(3)..close();
7792
}
78-
''').stream.toList(), completion(equals([1, 2, 3])));
79-
});
93+
''').stream.toList(),
94+
completion(equals([1, 2, 3])),
95+
);
96+
},
97+
);
8098

8199
test('allows a first parameter with type StreamChannel<Object?>', () {
82-
expect(spawnHybridCode('''
100+
expect(
101+
spawnHybridCode('''
83102
import "package:stream_channel/stream_channel.dart";
84103
85104
void hybridMain(StreamChannel<Object?> channel) {
86105
channel.sink..add(1)..add(2)..add(null)..close();
87106
}
88-
''').stream.toList(), completion(equals([1, 2, null])));
107+
''').stream.toList(),
108+
completion(equals([1, 2, null])),
109+
);
89110
});
90111

91112
test('gives a good error when the StreamChannel type is not supported', () {
92113
expect(
93-
spawnHybridCode('''
114+
spawnHybridCode('''
94115
import "package:stream_channel/stream_channel.dart";
95116
96117
void hybridMain(StreamChannel<Object> channel) {
97118
channel.sink..add(1)..add(2)..add(3)..close();
98119
}
99120
''').stream,
100-
emitsError(isA<Exception>().having(
101-
(e) => e.toString(),
102-
'toString',
103-
contains(
104-
'The first parameter to the top-level hybridMain() must be a '
105-
'StreamChannel<dynamic> or StreamChannel<Object?>. More specific '
106-
'types such as StreamChannel<Object> are not supported.'))));
121+
emitsError(
122+
isA<Exception>().having(
123+
(e) => e.toString(),
124+
'toString',
125+
contains(
126+
'The first parameter to the top-level hybridMain() must be a '
127+
'StreamChannel<dynamic> or StreamChannel<Object?>. More specific '
128+
'types such as StreamChannel<Object> are not supported.',
129+
),
130+
),
131+
),
132+
);
107133
});
108134

109135
test('can use dart:io even when run from a browser', () async {
110136
var path = p.join('test', 'hybrid_test.dart');
111-
expect(spawnHybridCode("""
137+
expect(
138+
spawnHybridCode("""
112139
import 'dart:io';
113140
114141
import 'package:stream_channel/stream_channel.dart';
@@ -118,7 +145,9 @@ void main() {
118145
..add(File(r"$path").readAsStringSync())
119146
..close();
120147
}
121-
""").stream.first, completion(contains('hybrid emits numbers')));
148+
""").stream.first,
149+
completion(contains('hybrid emits numbers')),
150+
);
122151
}, testOn: 'browser');
123152

124153
test('forwards data from the test to the hybrid isolate', () async {
@@ -147,15 +176,20 @@ void main() {
147176
}
148177
''';
149178

150-
expect(spawnHybridCode(code, message: [1, 2, 3]).stream.first,
151-
completion(equals([1, 2, 3])));
152-
expect(spawnHybridCode(code, message: {'a': 'b'}).stream.first,
153-
completion(equals({'a': 'b'})));
179+
expect(
180+
spawnHybridCode(code, message: [1, 2, 3]).stream.first,
181+
completion(equals([1, 2, 3])),
182+
);
183+
expect(
184+
spawnHybridCode(code, message: {'a': 'b'}).stream.first,
185+
completion(equals({'a': 'b'})),
186+
);
154187
});
155188

156-
test('allows the hybrid isolate to send errors across the stream channel',
157-
() {
158-
var channel = spawnHybridCode('''
189+
test(
190+
'allows the hybrid isolate to send errors across the stream channel',
191+
() {
192+
var channel = spawnHybridCode('''
159193
import "package:stack_trace/stack_trace.dart";
160194
import "package:stream_channel/stream_channel.dart";
161195
@@ -164,11 +198,15 @@ void main() {
164198
}
165199
''');
166200

167-
channel.stream.listen(null, onError: expectAsync2((error, stackTrace) {
168-
expect(error.toString(), equals('oh no!'));
169-
expect(stackTrace.toString(), contains('hybridMain'));
170-
}));
171-
});
201+
channel.stream.listen(
202+
null,
203+
onError: expectAsync2((error, stackTrace) {
204+
expect(error.toString(), equals('oh no!'));
205+
expect(stackTrace.toString(), contains('hybridMain'));
206+
}),
207+
);
208+
},
209+
);
172210

173211
test('sends an unhandled synchronous error across the stream channel', () {
174212
var channel = spawnHybridCode('''
@@ -179,10 +217,13 @@ void main() {
179217
}
180218
''');
181219

182-
channel.stream.listen(null, onError: expectAsync2((error, stackTrace) {
183-
expect(error.toString(), equals('oh no!'));
184-
expect(stackTrace.toString(), contains('hybridMain'));
185-
}));
220+
channel.stream.listen(
221+
null,
222+
onError: expectAsync2((error, stackTrace) {
223+
expect(error.toString(), equals('oh no!'));
224+
expect(stackTrace.toString(), contains('hybridMain'));
225+
}),
226+
);
186227
});
187228

188229
test('sends an unhandled asynchronous error across the stream channel', () {
@@ -198,10 +239,13 @@ void main() {
198239
}
199240
''');
200241

201-
channel.stream.listen(null, onError: expectAsync2((error, stackTrace) {
202-
expect(error.toString(), equals('oh no!'));
203-
expect(stackTrace.toString(), contains('hybridMain'));
204-
}));
242+
channel.stream.listen(
243+
null,
244+
onError: expectAsync2((error, stackTrace) {
245+
expect(error.toString(), equals('oh no!'));
246+
expect(stackTrace.toString(), contains('hybridMain'));
247+
}),
248+
);
205249
});
206250

207251
test('deserializes TestFailures as TestFailures', () {
@@ -228,31 +272,42 @@ void main() {
228272
expect(() => channel.sink.add(<Object>[].iterator), throwsArgumentError);
229273
});
230274

231-
test('gracefully handles an unserializable message in the browser',
232-
() async {
233-
var channel = spawnHybridCode('''
275+
test(
276+
'gracefully handles an unserializable message in the browser',
277+
() async {
278+
var channel = spawnHybridCode('''
234279
import 'package:stream_channel/stream_channel.dart';
235280
236281
void hybridMain(StreamChannel channel) {}
237282
''');
238283

239-
expect(() => channel.sink.add(<Object>[].iterator), throwsArgumentError);
240-
}, testOn: 'browser');
241-
242-
test('gracefully handles an unserializable message in the hybrid isolate',
243-
() {
244-
var channel = spawnHybridCode('''
284+
expect(
285+
() => channel.sink.add(<Object>[].iterator),
286+
throwsArgumentError,
287+
);
288+
},
289+
testOn: 'browser',
290+
);
291+
292+
test(
293+
'gracefully handles an unserializable message in the hybrid isolate',
294+
() {
295+
var channel = spawnHybridCode('''
245296
import "package:stream_channel/stream_channel.dart";
246297
247298
void hybridMain(StreamChannel channel) {
248299
channel.sink.add([].iterator);
249300
}
250301
''');
251302

252-
channel.stream.listen(null, onError: expectAsync1((error) {
253-
expect(error.toString(), contains("can't be JSON-encoded."));
254-
}));
255-
});
303+
channel.stream.listen(
304+
null,
305+
onError: expectAsync1((error) {
306+
expect(error.toString(), contains("can't be JSON-encoded."));
307+
}),
308+
);
309+
},
310+
);
256311

257312
test('forwards prints from the hybrid isolate', () {
258313
expect(() async {
@@ -272,14 +327,17 @@ void main() {
272327
// that's imported, URIs don't escape $ by default, and $ isn't allowed in
273328
// imports.
274329
test('supports a dollar character in the hybrid code', () {
275-
expect(spawnHybridCode(r'''
330+
expect(
331+
spawnHybridCode(r'''
276332
import "package:stream_channel/stream_channel.dart";
277333
278334
void hybridMain(StreamChannel channel) {
279335
var value = "bar";
280336
channel.sink.add("foo${value}baz");
281337
}
282-
''').stream.first, completion('foobarbaz'));
338+
''').stream.first,
339+
completion('foobarbaz'),
340+
);
283341
});
284342

285343
test('closes the channel when the hybrid isolate exits', () {
@@ -342,7 +400,8 @@ void main() {
342400
});
343401

344402
test('opts in to null safety by default', () async {
345-
expect(spawnHybridCode('''
403+
expect(
404+
spawnHybridCode('''
346405
import "package:stream_channel/stream_channel.dart";
347406
348407
// Use some null safety syntax
@@ -351,7 +410,9 @@ void main() {
351410
void hybridMain(StreamChannel channel) {
352411
channel.sink..add(1)..add(2)..add(3)..close();
353412
}
354-
''').stream.toList(), completion(equals([1, 2, 3])));
413+
''').stream.toList(),
414+
completion(equals([1, 2, 3])),
415+
);
355416
});
356417
});
357418
}

0 commit comments

Comments
 (0)