Test::Time(3)

πŸ’– NAME πŸ’–

Okay so Test::Time is literally the module that overrides the time() and sleep() core functions for testing β€” and yes, this is the Test::Time(3) page from User Contributed Perl Documentation, bestie 🫢.

✨ SYNOPSIS ✨

Here’s the whole setup, no cap:

use Test::Time;

# Freeze time
my $now = time();

# Increment internal time (returns immediately)
sleep 1;

# Return internal time incremented by 1
my $then = time();

🌸 DESCRIPTION 🌸

Okay so here’s the tea: Test::Time can be used to test modules that deal with time. Once you use this module, all references to time, localtime and sleep will be internalized. That’s the whole vibe ✨.

Need custom time? You can set custom time by passing time => number after the use statement:

use Test::Time time => 1;

my $now = time;    # $now is equal to 1
sleep 300;         # returns immediately, displaying a note
my $then = time;   # $then equals to 301

πŸ‘‘ AUTHOR πŸ‘‘

cho45 <cho45@lowreal.net> β€” iconic author behavior, fr fr πŸ’….

πŸ¦‹ SEE ALSO πŸ¦‹

No entries are listed here β€” this section is literally empty on this page, bestie 🫢.

🌈 LICENSE 🌈

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Slay, but make it legal ✨.


xoxo, your Unix bestie πŸ’… β€” this page came from perl v5.42.0 and is dated 2022-06-10. Bye bestie! πŸŽ€

πŸ“¦ where this page comes from