Test::use::ok(3pm)

✨ Test::use::ok ✨

okay bestie so this is a page from the Perl Programmers Reference Guide β€” Test::use::ok(3pm) to be exact β€” and it's literally the glow-up your test scripts have been waiting for πŸ’…

πŸŽ€ NAME πŸŽ€

Test::use::ok β€” the alternative to Test::More::use_ok. That's it, that's the whole vibe. πŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

use ok 'Some::Module';

look at that. a single space is doing SO much work here, i'm obsessed 😭

🌸 DESCRIPTION 🌸

ok so according to the Test::More documentation, the recommendation is to run use_ok() inside a BEGIN block β€” that way functions get exported at compile-time and prototypes are properly honored. periodt. ✨

basically, instead of writing this:

use_ok( 'Some::Module' );
use_ok( 'Other::Module' );

you should be writing this:

BEGIN { use_ok( 'Some::Module' ); }
BEGIN { use_ok( 'Other::Module' ); }

but here's the thing β€” and ngl this is so real of us β€” people often either forget to add BEGIN, or they mistakenly group use_ok with other tests in a single BEGIN block, which "can create subtle differences in execution order." subtle differences!! in execution order!! the chaos πŸ™ˆ

with this module, you simply change all use_ok in test scripts to use ok, and they will be executed at BEGIN time. iconic behavior. and the explicit space after use makes it clear that this is a single compile-time action β€” one action, one moment, main character energy πŸ‘‘

fr fr: that space isn't just cute, it's communicative. it's telling you "hey bestie, this all happens at compile time, as one thing." slay πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

  • Test::More β€” the og, the source of the recommendation above 🫢

πŸ‘‘ MAINTAINER πŸ‘‘

Chad Granum <exodist@cpan.org> β€” holding it down 🌈

πŸ’œ CC0 1.0 Universal πŸ’œ

To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Test::use::ok.

This work is published from Taiwan.

<https://creativecommons.org/publicdomain/zero/1.0/>

that's a public domain dedication, bestie β€” generous to a degree that is genuinely iconic πŸŽ€


⭐ and that's the whole page!! it shipped as part of perl v5.42.3, dated 2026-11-03, and it lives at Test::use::ok(3pm). go forth and use ok responsibly πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from