Skip to content

Commit b81f12a

Browse files
munificentcommit-bot@chromium.org
authored andcommitted
Migrate language_2/async_star to NNBD.
Change-Id: I0fa2ee2561dd0bc399d88868d790d56e6df3c94d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134940 Commit-Queue: Bob Nystrom <[email protected]> Auto-Submit: Bob Nystrom <[email protected]> Reviewed-by: Lasse R.H. Nielsen <[email protected]>
1 parent 1ec87d1 commit b81f12a

33 files changed

+2691
-25
lines changed

pkg/async_helper/lib/async_minitest.dart

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -151,61 +151,61 @@ dynamic expectAsync(Function f, {int count = 1}) {
151151
}
152152

153153
// Matchers
154-
typedef Matcher = void Function(Object);
154+
typedef Matcher = void Function(dynamic);
155155

156-
Matcher same(Object o) => (v) {
156+
Matcher same(dynamic o) => (v) {
157157
Expect.identical(o, v);
158158
};
159159

160-
Matcher equals(Object o) => (v) {
160+
Matcher equals(dynamic o) => (v) {
161161
Expect.deepEquals(o, v);
162162
};
163163

164-
Matcher greaterThan(num n) => (Object v) {
164+
Matcher greaterThan(num n) => (dynamic v) {
165165
Expect.type<num>(v);
166166
num value = v;
167167
if (value > n) return;
168168
Expect.fail("$v is not greater than $n");
169169
};
170170

171-
Matcher greaterThanOrEqualTo(num n) => (Object v) {
171+
Matcher greaterThanOrEqualTo(num n) => (dynamic v) {
172172
Expect.type<num>(v);
173173
num value = v;
174174
if (value >= n) return;
175175
Expect.fail("$v is not greater than $n");
176176
};
177177

178-
Matcher lessThan(num n) => (Object v) {
178+
Matcher lessThan(num n) => (dynamic v) {
179179
Expect.type<num>(v);
180180
num value = v;
181181
if (value < n) return;
182182
Expect.fail("$v is not less than $n");
183183
};
184184

185-
Matcher lessThanOrEqualTo(num n) => (Object v) {
185+
Matcher lessThanOrEqualTo(num n) => (dynamic v) {
186186
Expect.type<num>(v);
187187
num value = v;
188188
if (value <= n) return;
189189
Expect.fail("$v is not less than $n");
190190
};
191191

192-
void isTrue(Object v) {
192+
void isTrue(dynamic v) {
193193
Expect.isTrue(v);
194194
}
195195

196-
void isFalse(Object v) {
196+
void isFalse(dynamic v) {
197197
Expect.isFalse(v);
198198
}
199199

200-
void isNull(Object o) {
200+
void isNull(dynamic o) {
201201
Expect.isNull(o);
202202
}
203203

204-
bool isStateError(Object o) {
204+
bool isStateError(dynamic o) {
205205
Expect.type<StateError>(o);
206206
}
207207

208-
void _checkThrow<T>(Object v, void onError(error)) {
208+
void _checkThrow<T>(dynamic v, void onError(error)) {
209209
if (v is Future) {
210210
var test = _currentTest..asyncWait();
211211
v.then((_) {
@@ -223,17 +223,17 @@ void _checkThrow<T>(Object v, void onError(error)) {
223223
});
224224
}
225225

226-
void throws(Object v) {
227-
_checkThrow<Object>(v, null);
226+
void throws(dynamic v) {
227+
_checkThrow<Object>(v, (_) {});
228228
}
229229

230-
Matcher throwsA(matcher) => (Object o) {
231-
_checkThrow<Object>(o, (Object error) {
230+
Matcher throwsA(matcher) => (dynamic o) {
231+
_checkThrow<Object>(o, (error) {
232232
expect(error, matcher);
233233
});
234234
};
235235

236-
Matcher completion(matcher) => (Object o) {
236+
Matcher completion(matcher) => (dynamic o) {
237237
Expect.type<Future>(o);
238238
Future future = o;
239239
_currentTest.asyncWait();
@@ -243,7 +243,7 @@ Matcher completion(matcher) => (Object o) {
243243
});
244244
};
245245

246-
void completes(Object o) {
246+
void completes(dynamic o) {
247247
Expect.type<Future>(o);
248248
Future future = o;
249249
_currentTest.asyncWait();
@@ -252,30 +252,30 @@ void completes(Object o) {
252252
});
253253
}
254254

255-
void isMap(Object o) {
255+
void isMap(dynamic o) {
256256
Expect.type<Map>(o);
257257
}
258258

259-
void isList(Object o) {
259+
void isList(dynamic o) {
260260
Expect.type<List>(o);
261261
}
262262

263-
void isNotNull(Object o) {
263+
void isNotNull(dynamic o) {
264264
Expect.isNotNull(o);
265265
}
266266

267267
abstract class _Matcher {
268-
void call(Object o);
268+
void call(dynamic o);
269269
}
270270

271271
class isInstanceOf<T> implements _Matcher {
272-
void call(Object o) {
272+
void call(dynamic o) {
273273
Expect.type<T>(o);
274274
}
275275
}
276276

277-
void throwsArgumentError(Object v) {
278-
_checkThrow<ArgumentError>(v, null);
277+
void throwsArgumentError(dynamic v) {
278+
_checkThrow<ArgumentError>(v, (_) {});
279279
}
280280

281281
String fail(String message) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library async_start_test;
6+
7+
import "dart:async";
8+
9+
import "package:expect/expect.dart";
10+
11+
void main() async {
12+
var results = [];
13+
14+
f() async* {
15+
yield 0;
16+
yield 1;
17+
yield 2;
18+
}
19+
20+
//Broken, the value 1 was lost.
21+
await for (var i in f()) {
22+
results.add(i);
23+
if (i == 0) {
24+
// This should pause the stream subscription.
25+
await Future.delayed(Duration(milliseconds: 500));
26+
}
27+
}
28+
29+
Expect.listEquals([0, 1, 2], results);
30+
}

0 commit comments

Comments
 (0)