1Test::Future::AsyncAwaiUts:e:rAwCaointtarbilbeu(t3e)d PeTrelstD:o:cFuumteunrtea:t:iAosnyncAwait::Awaitable(3)
2
3
4

NAME

6       "Test::Future::AsyncAwait::Awaitable" - conformance tests for awaitable
7       role API
8

SYNOPSIS

10          use Test::More;
11          use Test::Future::AsyncAwait::Awaitable;
12
13          use My::Future::Subclass;
14
15          test_awaitable "My subclass of Future",
16             class => "My::Future::Subclass";
17
18          done_testing;
19

DESCRIPTION

21       This module provides a single test function, which runs a suite of
22       subtests to check that a given class provides a useable implementation
23       of the Future::AsyncAwait::Awaitable role. It runs tests that simulate
24       various ways in which Future::AsyncAwait will try to use an instance of
25       this class, to check that the implementation is valid.
26

FUNCTIONS

28   test_awaitable
29          test_awaitable( $title, %args )
30
31       Runs the API conformance tests. $title is printed in the test
32       description output so should be some human-friendly string.
33
34       Takes the following named arguments:
35
36       class => STRING
37           Gives the name of the class. This is the class on which the
38           "AWAIT_NEW_DONE" and "AWAIT_NEW_FAIL" methods will be invoked.
39
40       new => CODE
41           Optional. Gives a callback function to invoke to construct a new
42           pending instance; used by the tests to create pending instances
43           that would be passed into the "await" keyword. As this is not part
44           of the API as such, the test code does not rely on being able to
45           directly perform it via the API.
46
47           This argument is optional; if not provided the tests will simply
48           try to invoke the regular "new" constructor on the given class
49           name. For most implementations this should be sufficient.
50
51              $f = $new->()
52
53       cancel => CODE
54           Optional. Gives a callback function to invoke to cancel a pending
55           instance, if the implementation provides cancellation semantics. If
56           this callback is provided then an extra subtest suite is run to
57           check the API around cancellation.
58
59              $cancel->( $f )
60
61       force => CODE
62           Optional. Gives a callback function to invoke to wait for a promise
63           to invoke its on-ready callbacks. Some future-like implementations
64           will run these immediately when the future is marked as done or
65           failed, and so this callback will not be required. Other
66           implementations will defer these invocations, perhaps until the
67           next tick of an event loop or similar. In the latter case, these
68           implementations should provide a way for the test to wait for this
69           to happen.
70
71              $force->( $f )
72

AUTHOR

74       Paul Evans <leonerd@leonerd.org.uk>
75
76
77
78perl v5.36.0                      2023-02T-e1s5t::Future::AsyncAwait::Awaitable(3)
Impressum