GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Future(3) User Contributed Perl Documentation Test::Future(3)

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

 use Test::More tests => 2;
 use Test::Future;

 no_pending_futures {
    my $f = some_function();

    is( $f->get, "result", 'Result of the some_function()' );
 } 'some_function() leaves no pending Futures';

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

   no_pending_futures( \&code, $name )

Since version 0.29.

Runs the given block of code, while keeping track of every "Future" instance constructed while doing so. After the code has returned, each of these instances are inspected to check that they are not still pending. If they are all either ready (by success or failure) or cancelled, the test will pass. If any are still pending then the test fails.

If Devel::MAT is installed, it will be used to write a memory state dump after a failure. It will create a .pmat file named the same as the unit test, but with the trailing .t suffix replaced with -TEST.pmat where "TEST" is the number of the test that failed (in case there was more than one). A list of addresses of "Future" instances that are still pending is also printed to assist in debugging the issue.

It is not an error if the code does not construct any "Future" instances at all. The block of code may contain other testing assertions; they will be run before the assertion by "no_pending_futures" itself.

Paul Evans <leonerd@leonerd.org.uk>
2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.