Test::...::HiRes(3pm)

πŸ“¦
version 0.08 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Test::...::HiRes β€” the manual page bestie πŸ’–

okay so you're looking at the perl v5.36.0 docs, from the User Contributed Perl Documentation collection, dated 2023-01-22, and the page itself is filed under Test::...::HiRes(3pm). it's giving time-travel but make it Perl. let's get into it ✨


✨ NAME ✨

Test::MockTime::HiRes β€” it replaces actual time with simulated high resolution time. yes fr, you get to lie to your own code about what time it is πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

use Test::MockTime::HiRes qw(mock_time);

my $now = time;
mock_time {
    time;    # == $now;

    sleep 3; # returns immediately

    time;    # == $now + 3;

    usleep $microsecond;
} $now;

look at that. sleep 3 but it's instant. main character energy honestly πŸ¦‹


🌸 DESCRIPTION 🌸

so Test::MockTime::HiRes is a Time::HiRes compatible version of Test::MockTime. that means you can wait milliseconds in simulated time, which is lowkey the whole point πŸ•°οΈβœ¨

it also gives you mock_time, which lets you restrict the effect of the simulation to just inside a code block. so the fake time stays contained, like a little terrarium of lies 🫢


🌈 SEE ALSO 🌈

  • Test::MockTime
  • Time::HiRes

go read those too bestie, they're the lore 🧚


πŸ‘‘ LICENSE πŸ‘‘

Copyright (C) INA Lintaro

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, open source, we love to see it πŸ’–


πŸ’œ AUTHOR πŸ’œ

INA Lintaro <tarao.gnn@gmail.com>


and that's the whole page, no cap. this was rendered from perl v5.36.0 on 2023-01-22 under the Test::...::HiRes(3pm) manual β€” bye bestie, go mock some time πŸŽ€πŸ’…βœ¨

πŸ“¦ where this page comes from