Expand description
Task related testing utilities.
This module provides utilities for creating test
Context
s,
Waker
s and
Spawn
implementations.
Test contexts:
noop_context
creates a context that ignores calls tocx.waker().wake_by_ref()
.panic_context
creates a context that panics whencx.waker().wake_by_ref()
is called.
Test wakers:
noop_waker
creates a waker that ignores calls towake
.panic_waker
creates a waker that panics whenwake
is called.new_count_waker
creates a waker that increments a counter wheneverwake
is called.
Test spawners:
NoopSpawner
ignores calls tospawn
PanicSpawner
panics ifspawn
is called.RecordSpawner
records the spawned futures.
For convenience there additionally exist various functions that directly
return waker/spawner references: noop_waker_ref
, panic_waker_ref
,
noop_spawner_mut
and panic_spawner_mut
.
Structs§
- Number of times the waker was awoken.
- An implementation of
Spawn
that discards spawned futures when used. - An implementation of
Spawn
that panics when used.
Functions§
- Create a new
Waker
that counts the number of times it’s awoken. - Get a reference to a singleton instance of
NoopSpawner
. - Create a new
Waker
which does nothing whenwake()
is called on it. - Get a static reference to a
Waker
which does nothing whenwake()
is called on it. - Get a reference to a singleton instance of
PanicSpawner
.