Test2::Handle(3perl)
π NAME π
Test2::Handle β the base class for Test2 handles, bestie, the ones you use inside V# bundles β¨
πΈ DESCRIPTION πΈ
Okay so picture this: you're writing a test, you use the T2() function in something that runs on Test2::V1, and the thing you get back and poke at? that's this. That's the whole vibe. It's the handle, it's the main character, and this page is its origin story π«Ά
β¨ SYNOPSIS β¨
π RECOMMENDED (the way you should be doing it, no cap)
use Test2::V1;
my $handle = T2();
$handle->ok(1, "Passing Test");
π¦ WITHOUT SUGAR (raw-dogging it, we respect it)
use Test2::Handle();
my $handle = Test2::Handle->new(base => 'Test2::V1::Base');
$handle->ok(1, "Passing test");
π METHODS π
Okay so here's the tea: most methods get delegated to the base class you handed over at construction time. But there's a lil handful of methods that this package defines all on its own, and those are the ones we're gonna go through. Sit down, get comfy π
$base = $class_or_inst->DEFAULT_HANDLE_BASEβ hands you back the default handle base. And here's the thing: on the base handle class itself, this one throws an exception. So like, you're supposed to override it in a subclass, bestie. Don't try to use the original one, it will not work, it's giving "no" π$base = $inst->HANDLE_BASEβ in this base class, this method always throws an exception. Always? Always. Every single time. But in a subclass, it should return the default base class you wanna use for that subclass. That's the job. That's its whole purpose β¨$namespace = $inst->HANDLE_NAMESPACEβ grabs the namespace that we use to store all the functions we wrap up as methods π₯@sub_names = $inst->HANDLE_SUBSβ gives you a list of every sub that's available in the handle namespace. All of them. The whole roster π$inst->HANDLE_INCLUDE($package, @subs)β pulls the specified subs out of the specified package and imports them right into our internal namespace. Very "you belong to me now" energy π$inst = $class->import()β this is the one that makes aT2()sub appear in your namespace at import time. Sprinkles it right in there like glitter π$inst->init()β internal business, bestie. It initializes and validates the handle object. That's it, that's the job π§
β AUTOLOAD β
Internally used to wrap functions as methods. That's the whole thing. Iconic behaviour, truly π
π₯ SOURCE π₯
The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/. Go be nosy, you're allowed π«Ά
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright Chad Granum <exodist@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
okay that's the whole page bestie, you ate that, periodt π
β¨ This was Test2::Handle(3perl), hanging out in perl v5.44.0, dated 2026-10-17 β love u, go write some passing tests π¦πΈ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms