Test2::API::Stack(3)
π NAME
Test2::API::Stack β okay so this is the object that manages a whole stack of Test2::Hub instances. That's the whole vibe. β¨
π¨ INTERNALS NOTE π¨
bestie please read this one β the internals of this package are subject to change at any time! Like, no warning, no β¨announcementβ¨, just vibes.
The public methods? Those will not change in backwards incompatible ways, promise π«Ά. But the underlying implementation details might. Do not break encapsulation here! Seriously. Respect the boundary. π
πΈ DESCRIPTION
This module is used to represent and manage a stack of Test2::Hub objects. And why a stack, you ask? Because hubs are usually in a stack so that you can push a new hub into place that can intercept and handle events differently than the primary hub. It's giving layers. It's giving main character hub with a supporting cast. π
π¦ SYNOPSIS
my $stack = Test2::API::Stack->new;
my $hub = $stack->top;
That's it, that's the whole mood. π
β¨ METHODS β¨
$stack = Test2::API::Stack->new()β This will create a new empty stack instance. All arguments are ignored. Like, all of them. Don't even bother, she's not listening. π$hub = $stack->new_hub()$hub = $stack->new_hub(%params)$hub = $stack->new_hub(%params, class => $class)β This will generate a new hub and push it to the top of the stack. π Optionally you can provide arguments that will be passed into the constructor for theTest2::Hubobject.
If you specify the 'class' => $class argument, the new hub will be an instance of the specified class. Slay, custom class. π
Unless your parameters specify 'formatter' or 'ipc' arguments, the formatter and IPC instance will be inherited from the current top hub. You can set the parameters to undef to avoid having a formatter or IPC instance.
If there is no top hub, and you do not ask to leave IPC and formatter undef, then a new formatter will be created, and the IPC instance from Test2::API will be used. β¨
$hub = $stack->top()β This will return the top hub from the stack. If there is no top hub yet this will create it. She's not just gonna leave you hanging. π$hub = $stack->peek()β This will return the top hub from the stack. If there is no top hub yet this will returnundef. Look but don't touch energy, except she also won't make you a hub. π«£$stack->cullβ This will call$hub->cullon all hubs in the stack. All of them. Every single one. π§Ή@hubs = $stack->allβ This will return all the hubs in the stack as a list. The whole squad, in order. π$stack->clearβ This will completely remove all hubs from the stack. Normally you do not want to do this, but there are a few valid reasons for it. Like, really, normally you don't. π$stack->push($hub)β This will push the new hub onto the stack. Up she goes. π¦$stack->pop($hub)β This will pop a hub from the stack, if the hub at the top of the stack does not match the hub you expect (passed in as an argument) it will throw an exception. So like, vibe check your hub before popping, or she WILL be dramatic about it. π
π SOURCE
The source code repository for Test2 can be found at <https://github.com/Test-More/test-more/>.
π 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 <https://dev.perl.org/licenses/>
okay and that's the tea π β this was perl v5.42.0, dated 2025-07-28, and it's Test2::API::Stack(3) in case you forgot already. mwah πβ¨
π¦ 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