Skip to content

Commit

Permalink
Accept extra runs in test. Move to Dart 3.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrhn committed Jan 24, 2025
1 parent 4bd5497 commit a56fa94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkgs/fake_async/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
testing.
repository: https://github.com/dart-lang/test/tree/master/pkgs/fake_async
environment:
sdk: ^3.3.0
sdk: ^3.5.0

dependencies:
clock: ^1.1.0
Expand Down
17 changes: 11 additions & 6 deletions pkgs/fake_async/test/fake_async_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -829,15 +829,16 @@ void main() {
log.clear();

async.flushMicrotasks();
expect(log, ['run0', '#1()']);
// Some zone implementations may introduce extra `run` calls.
expect(log.tail(2), ['run0', '#1()']);
log.clear();

async.elapse(elapseBy);
expect(log, ['run0', '#2()']);
expect(log.tail(2), ['run0', '#2()']);
log.clear();

async.elapse(elapseBy);
expect(log, ['run1', '#3(_)']);
expect(log.tail(2), ['run1', '#3(_)']);

zone.run(() {
log.clear();
Expand All @@ -852,15 +853,15 @@ void main() {
log.clear();

async.flushMicrotasks();
expect(log, ['run0', '#4()', 'ERR(microtask error)']);
expect(log.tail(3), ['run0', '#4()', 'ERR(microtask error)']);
log.clear();

async.elapse(elapseBy);
expect(log, ['run0', '#5()', 'ERR(timer error)']);
expect(log.tail(3), ['run0', '#5()', 'ERR(timer error)']);
log.clear();

async.elapse(elapseBy);
expect(log, ['run1', '#3(_)', 'ERR(periodic timer error)']);
expect(log.tail(3), ['run1', '#3(_)', 'ERR(periodic timer error)']);
log.clear();
});
});
Expand All @@ -872,3 +873,7 @@ Matcher _closeToTime(DateTime expected) => predicate(
(actual) =>
expected.difference(actual as DateTime).inMilliseconds.abs() < 100,
'is close to $expected');

extension<T> on List<T> {
List<T> tail(int count) => sublist(length - count);
}

0 comments on commit a56fa94

Please sign in to comment.