| 1 |
NAME |
| 2 |
Test::Time - Overrides the time() and sleep() core functions for testing |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Test::Time; |
| 6 |
|
| 7 |
# Freeze time |
| 8 |
my $now = time(); |
| 9 |
|
| 10 |
# Increment internal time (returns immediately) |
| 11 |
sleep 1; |
| 12 |
|
| 13 |
# Return internal time incremented by 1 |
| 14 |
my $then = time(); |
| 15 |
|
| 16 |
DESCRIPTION |
| 17 |
Test::Time can be used to test modules that deal with time. Once you |
| 18 |
"use" this module, all references to "time" and "sleep" will be |
| 19 |
internalized. You can set custom time by passing time => number after |
| 20 |
the "use" statement: |
| 21 |
|
| 22 |
use Test::Time time => 1; |
| 23 |
|
| 24 |
my $now = time; # $now is equal to 1 |
| 25 |
sleep 300; # returns immediately, displaying a note |
| 26 |
my $then = time; # $then equals to 301 |
| 27 |
|
| 28 |
AUTHOR |
| 29 |
cho45 <[email protected]> |
| 30 |
|
| 31 |
SEE ALSO |
| 32 |
LICENSE |
| 33 |
This library is free software; you can redistribute it and/or modify it |
| 34 |
under the same terms as Perl itself. |
| 35 |
|