TEST2::API::STACK(3perl)
β¨ Test2::API::Stack β¨
okay so bestie, you know how Perl's test suite is basically a whole universe?? this is the page from the Perl Programmers Reference Guide for Test2::API::Stack, and it's lowkey the bouncer at the club that decides which hub is on top π
π NAME π
Test2::API::Stack β the object that manages a whole stack of Test2::Hub instances. it's giving middle management but make it iconic π«Ά
π¨ INTERNALS NOTE π¨
bestie. READ THIS. the internals of this package can change at ANY time, no cap π the public methods will never change in backwards-incompatible ways, but the underlying implementation details absolutely might. so do not break encapsulation here, i am begging π
πΈ DESCRIPTION πΈ
this module is used to represent and manage a stack of Test2::Hub objects. why a stack tho?? because hubs usually live in a stack so you can push a brand-new hub into place that intercepts and handles events differently than the primary hub. main character hub vs. understudy hub, they're both slaying in their own lane π
π SYNOPSIS π
my $stack = Test2::API::Stack->new;
my $hub = $stack->top;
that's it. that's the vibe. β¨
π METHODS π
$stack = Test2::API::Stack->new()β makes you a shiny new empty stack instance. every argument you pass?? ignored. completely. they do not get a word in, periodt π$hub = $stack->new_hub()$hub = $stack->new_hub(%params)$hub = $stack->new_hub(%params, class => $class)β this generates a new hub and pushes it right to the top of the stack, like it's auditioning for the lead role π optionally you can hand it arguments that get passed straight into the constructor for theTest2::Hubobject.
if you specify the 'class' => $class argument, the new hub will be an instance of the class you named β custom hub, custom vibes.
unless your params specify 'formatter' or 'ipc' arguments, the formatter and the IPC instance get inherited from the current top hub (yes, it's nepotism, but make it functional). you can set those params to "undef" if you want to avoid having a formatter or an IPC instance at all β no formatter, no IPC, no problem.
and if there's no top hub, and you didn't ask to leave IPC and formatter undef?? then a new formatter gets created, and the IPC instance from Test2::API will be used. it's giving "we'll figure it out" energy.
$hub = $stack->top()β returns the top hub from the stack. and if there's no top hub yet?? it literally creates one for you. so helpful π«Ά$hub = $stack->peek()β returns the top hub from the stack too, BUT if there's no top hub yet it returnsundefinstead. look don't touch, bestie π$stack->cullβ calls$hub->cullon all the hubs in the stack. every single one. it's a group thing.@hubs = $stack->allβ returns all the hubs in the stack as a list. the whole friend group, assembled π$stack->clearβ completely removes all hubs from the stack. > normally you do NOT want to do this, bestie π but there are a few valid reasons for it, so it stays legal.$stack->push($hub)β pushes the new hub onto the stack. new hub, who dis.$stack->pop($hub)β pops a hub from the stack. BUT if the hub at the top of the stack does not match the hub you expected (the one you passed in as an argument)?? it will throw an exception. it checks IDs at the door and it will NOT be nice about it π
π₯ SOURCE π₯
the source code repository for Test2 lives at https://github.com/Test-More/test-more/ β go be nosy, it's encouraged β
π§ 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. iconic behaviour, honestly π
see https://dev.perl.org/licenses/ for the receipts π
aaaand that's the whole thing, bestie!! this page ships with perl v5.44.0 and is dated 2026-10-17 π go forth and manage your hub stack like the main character you are, mwah πβ¨
π¦ 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