1Test::Future(3)       User Contributed Perl Documentation      Test::Future(3)
2
3
4

NAME

6       "Test::Future" - unit test assertions for Future instances
7

SYNOPSIS

9        use Test::More tests => 2;
10        use Test::Future;
11
12        no_pending_futures {
13           my $f = some_function();
14
15           is( $f->get, "result", 'Result of the some_function()' );
16        } 'some_function() leaves no pending Futures';
17

DESCRIPTION

19       This module provides unit testing assertions that may be useful when
20       testing code based on, or using Future instances or subclasses.
21

FUNCTIONS

23   no_pending_futures
24          no_pending_futures( \&code, $name )
25
26       Since version 0.29.
27
28       Runs the given block of code, while keeping track of every "Future"
29       instance constructed while doing so. After the code has returned, each
30       of these instances are inspected to check that they are not still
31       pending. If they are all either ready (by success or failure) or
32       cancelled, the test will pass. If any are still pending then the test
33       fails.
34
35       If Devel::MAT is installed, it will be used to write a memory state
36       dump after a failure. It will create a .pmat file named the same as the
37       unit test, but with the trailing .t suffix replaced with -TEST.pmat
38       where "TEST" is the number of the test that failed (in case there was
39       more than one). A list of addresses of "Future" instances that are
40       still pending is also printed to assist in debugging the issue.
41
42       It is not an error if the code does not construct any "Future"
43       instances at all. The block of code may contain other testing
44       assertions; they will be run before the assertion by
45       "no_pending_futures" itself.
46

AUTHOR

48       Paul Evans <leonerd@leonerd.org.uk>
49
50
51
52perl v5.30.0                      2019-07-26                   Test::Future(3)
Impressum