Test::use::ok(3)
πΈ NAME πΈ
Okay so bestie, welcome to the Test::use::ok(3) page β from the User Contributed Perl Documentation shelf, no less. This module is literally the alternative to Test::More::use_ok, and its whole vibe is making your test scripts behave at BEGIN time without you having to remember extra BEGIN scaffolding. Iconic behavior, honestly.
β¨ SYNOPSIS β¨
use ok 'Some::Module';
Thatβs it. Thatβs the whole synopsis. Short, sweet, and serving main character energy π .
π¦ DESCRIPTION π¦
So, according to the Test::More documentation, the recommended move is to run use_ok() inside a BEGIN block β that way functions are exported at compile-time and prototypes are properly honored. The docs said it, so we respect it, periodt.
That means instead of writing this:
use_ok( 'Some::Module' );
use_ok( 'Other::Module' );
You should write this:
BEGIN { use_ok( 'Some::Module' ); }
BEGIN { use_ok( 'Other::Module' ); }
And likeβ¦ valid. But ngl, people often either forget to add BEGIN, or they mistakenly group use_ok with other tests in a single BEGIN block. And that can create subtle differences in execution order. Not a slay. More of a βwait, why is this test acting weirdβ moment π.
With this module, you simply change all use_ok in test scripts to use ok, and they will be executed at BEGIN time. The explicit space after use makes it clear that this is a single compile-time action. The way that works is genuinely so clean. Obsessed π«Ά.
π₯ SEE ALSO π₯
Test::Moreβ the icon, the legend, the reference point. Go read it, iykyk π.
π MAINTAINER π
Chad Granum <exodist@cpan.org> β thatβs the maintainer, bestie. Respect the name, fr fr π.
π 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/>
Sign-off sparkle: this adorable little page is rockinβ perl v5.42.0, dated 2025-07-28, and yes bestie, itβs still Test::use::ok(3) β bye, love u, go write those tests πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Simple 1.302214-bp160.1.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms