Test2::API::Stack(3)

πŸ“¦ version 1.302214, in opensuse-leap 16.0

πŸ’… 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 the Test2::Hub object.

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 return undef. Look but don't touch energy, except she also won't make you a hub. 🫣
  • $stack->cull β€” This will call $hub->cull on 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 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