23 Sep 2022 22:35:21 UTC
- Distribution: Future-AsyncAwait
- Module version: 0.59
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (19)
- Testers (269 / 8 / 8)
- KwaliteeBus factor: 1
- 67.87% Coverage
- License: perl_5
- Perl: v5.16.0
- Activity24 month
- Download (80.03KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Test::Future::AsyncAwait::Awaitable- conformance tests for awaitable role API
use Test::More; use Test::Future::AsyncAwait::Awaitable; use My::Future::Subclass; test_awaitable "My subclass of Future", class => "My::Future::Subclass"; done_testing;
This module provides a single test function, which runs a suite of subtests to check that a given class provides a useable implementation of the Future::AsyncAwait::Awaitable role. It runs tests that simulate various ways in which Future::AsyncAwait will try to use an instance of this class, to check that the implementation is valid.
test_awaitable( $title, %args )
Runs the API conformance tests.
$titleis printed in the test description output so should be some human-friendly string.
Takes the following named arguments:
- class => STRING
Gives the name of the class. This is the class on which the
AWAIT_NEW_FAILmethods will be invoked.
- new => CODE
Optional. Gives a callback function to invoke to construct a new pending instance; used by the tests to create pending instances that would be passed into the
awaitkeyword. As this is not part of the API as such, the test code does not rely on being able to directly perform it via the API.
This argument is optional; if not provided the tests will simply try to invoke the regular
newconstructor on the given class name. For most implementations this should be sufficient.
$f = $new->()
- cancel => CODE
Optional. Gives a callback function to invoke to cancel a pending instance, if the implementation provides cancellation semantics. If this callback is provided then an extra subtest suite is run to check the API around cancellation.
$cancel->( $f )
- force => CODE
Optional. Gives a callback function to invoke to wait for a promise to invoke its on-ready callbacks. Some future-like implementations will run these immediately when the future is marked as done or failed, and so this callback will not be required. Other implementations will defer these invocations, perhaps until the next tick of an event loop or similar. In the latter case, these implementations should provide a way for the test to wait for this to happen.
$force->( $f )
Paul Evans <firstname.lastname@example.org>
Module Install Instructions
To install Future::AsyncAwait, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Future::AsyncAwait
For more information on module installation, please visit the detailed CPAN module installation guide.