1Test::Time(3) User Contributed Perl Documentation Test::Time(3)
2
3
4
6 Test::Time - Overrides the time() and sleep() core functions for
7 testing
8
10 use Test::Time;
11
12 # Freeze time
13 my $now = time();
14
15 # Increment internal time (returns immediately)
16 sleep 1;
17
18 # Return internal time incremented by 1
19 my $then = time();
20
22 Test::Time can be used to test modules that deal with time. Once you
23 "use" this module, all references to "time", "localtime" and "sleep"
24 will be internalized. You can set custom time by passing time =>
25 number after the "use" statement:
26
27 use Test::Time time => 1;
28
29 my $now = time; # $now is equal to 1
30 sleep 300; # returns immediately, displaying a note
31 my $then = time; # $then equals to 301
32
34 cho45 <cho45@lowreal.net>
35
38 This library is free software; you can redistribute it and/or modify it
39 under the same terms as Perl itself.
40
41
42
43perl v5.36.0 2022-07-22 Test::Time(3)