X Tutup
Skip to content

Commit 53694eb

Browse files
committed
feat(FakeAsync): check pending timers at the end of fakeAsync in Dart
Made possible with quiver 0.21.4
1 parent 31a3a19 commit 53694eb

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

modules/angular2/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
logging: '>=0.9.0 <0.12.0'
1818
source_span: '^1.0.0'
1919
stack_trace: '^1.1.1'
20-
quiver: '^0.21.3+1'
20+
quiver: '^0.21.4'
2121
dev_dependencies:
2222
guinness: '^0.1.17'
2323
transformers:

modules/angular2/src/test_lib/fake_async.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@ Function fakeAsync(Function fn) {
3030
return new quiver.FakeAsync().run((quiver.FakeAsync async) {
3131
try {
3232
_fakeAsync = async;
33-
List args = [
34-
a0,
35-
a1,
36-
a2,
37-
a3,
38-
a4,
39-
a5,
40-
a6,
41-
a7,
42-
a8,
43-
a9
44-
].takeWhile((a) => a != _u).toList();
33+
List args = [a0, a1, a2, a3, a4, a5, a6, a7, a8, a9]
34+
.takeWhile((a) => a != _u).toList();
4535
var res = Function.apply(fn, args);
4636
_fakeAsync.flushMicrotasks();
37+
38+
if (async.periodicTimerCount > 0) {
39+
throw new BaseException('${async.periodicTimerCount} periodic '
40+
'timer(s) still in the queue.');
41+
}
42+
43+
if (async.nonPeriodicTimerCount > 0) {
44+
throw new BaseException('${async.nonPeriodicTimerCount} timer(s) '
45+
'still in the queue.');
46+
}
47+
4748
return res;
4849
} finally {
4950
_fakeAsync = null;

modules/angular2/test/test_lib/fake_async_spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,11 @@ export function main() {
158158
}));
159159

160160
it('should throw an error on dangling timers', () => {
161-
// TODO(vicb): https://github.com/google/quiver-dart/issues/248
162-
if (IS_DARTIUM) return;
163161
expect(() => { fakeAsync(() => { TimerWrapper.setTimeout(() => {}, 10); })(); })
164162
.toThrowError('1 timer(s) still in the queue.');
165163
});
166164

167165
it('should throw an error on dangling periodic timers', () => {
168-
// TODO(vicb): https://github.com/google/quiver-dart/issues/248
169-
if (IS_DARTIUM) return;
170166
expect(() => { fakeAsync(() => { TimerWrapper.setInterval(() => {}, 10); })(); })
171167
.toThrowError('1 periodic timer(s) still in the queue.');
172168
});

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ environment:
44
dev_dependencies:
55
guinness: '^0.1.17'
66
unittest: '^0.11.5+4'
7-
quiver: '^0.21.3+1'
7+
quiver: '^0.21.4'

0 commit comments

Comments
 (0)
X Tutup