[][src]Module futures_test::task

Task related testing utilities.

This module provides utilities for creating test LocalWakers and Spawn implementations.

Test wakers:

  • [noop_local_waker] creates a waker that ignores calls to wake.
  • [panic_local_waker] creates a waker that panics when wake is called.
  • [new_count_waker] creates a waker that increments a counter whenever wake is called.

Test spawners:

  • [NoopSpawner] ignores calls to spawn
  • [PanicSpawner] panics if spawn is called.
  • [RecordSpawner] records the spawned futures.

For convenience there additionally exist various functions that directly return waker/spawner references: [noop_local_waker_ref], [panic_local_waker_ref], [noop_spawner_mut] and [panic_spawner_mut].

Structs

AwokenCount

Number of times the waker was awoken.

NoopSpawner

An implementation of Spawn that discards spawned futures when used.

PanicSpawner

An implementation of Spawn that panics when used.

PanicWake

An implementation of Wake that panics when woken.

RecordSpawner

An implementation of Spawn that records any Futures spawned on it.

Functions

new_count_waker

Create a new LocalWaker that counts the number of times it's awoken.

noop_local_waker

Create a new LocalWaker referencing a singleton instance of [NoopWake].

noop_local_waker_ref

Get a thread local reference to a LocalWaker referencing a singleton instance of [NoopWake].

noop_spawner_mut

Get a reference to a singleton instance of NoopSpawner.

panic_local_waker

Create a new LocalWaker referencing a singleton instance of PanicWake.

panic_local_waker_ref

Get a thread local reference to a LocalWaker referencing a singleton instance of PanicWake.

panic_spawner_mut

Get a reference to a singleton instance of PanicSpawner.