Skip to content

Commit

Permalink
Tighten types in test utils
Browse files Browse the repository at this point in the history
Towards #2095

Use `Queue.of` to infer the collection type from the argument instead of
`Queue.from` which ignores the argument type.

Expand a bare `Function` to a full signature function type.
  • Loading branch information
natebosch committed Sep 20, 2023
1 parent 8191a35 commit 8bd0846
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkgs/test/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ State? lastState;
///
/// The most recent emitted state is stored in [_lastState].
void expectStates(LiveTest liveTest, Iterable<State> statesIter) {
var states = Queue.from(statesIter);
var states = Queue.of(statesIter);
liveTest.onStateChange.listen(expectAsync1((state) {
lastState = state;
expect(state, equals(states.removeFirst()));
Expand All @@ -50,8 +50,9 @@ void expectStates(LiveTest liveTest, Iterable<State> statesIter) {

/// Asserts that errors will be emitted via [liveTest.onError] that match
/// [validators], in order.
void expectErrors(LiveTest liveTest, Iterable<Function> validatorsIter) {
var validators = Queue.from(validatorsIter);
void expectErrors(
LiveTest liveTest, Iterable<void Function(Object)> validatorsIter) {
var validators = Queue.of(validatorsIter);
liveTest.onError.listen(expectAsync1((error) {
validators.removeFirst()(error.error);
}, count: validators.length, max: validators.length));
Expand Down

0 comments on commit 8bd0846

Please sign in to comment.