1Test::Future::Deferred(U3s)er Contributed Perl DocumentatTieosnt::Future::Deferred(3)
2
3
4
6 "Test::Future::Deferred" - a future which completes later
7
8 my $future = Test::Future::Deferred->done_later( 1, 2, 3 );
9
10 # Future is not ready yet
11
12 my @result = $future->get;
13
15 This subclass of Future provides two new methods and an implementation
16 of the "await" interface, which allows the futures to appear pending at
17 first, but then to complete when "get" is called at the toplevel on one
18 of them.
19
20 This behaviour is useful in unit tests to check that behaviour of a
21 module under test is correct even with non-immediate futures, as it
22 allows a future to easily be constructed that will complete "soon", but
23 not yet, without needing an event loop.
24
25 Because these futures provide their own "await" method, they shouldn't
26 be mixed in the same program with other kinds of futures from real
27 event systems or similar.
28
30 done_later
31 $f->done_later( @args )
32
33 Equivalent to invoking the regular "done" method as part of the "await"
34 operation called on the toplevel future. This makes the future complete
35 with the given result, but only when "get" is called.
36
37 fail_later
38 $f->fail_later( $message, $category, @details )
39
40 Equivalent to invoking the regular "fail" method as part of the "await"
41 operation called on the toplevel future. This makes the future complete
42 with the given failure, but only when "get" is called. As the "failure"
43 method also waits for completion of the future, then it will return the
44 failure message given here also.
45
47 Paul Evans <leonerd@leonerd.org.uk>
48
49
50
51perl v5.30.1 2020-01-30 Test::Future::Deferred(3)