Test2::API::Stack(3p) Perl Programmers Reference Guide Test2::API::Stack(3p) #
Test2::API::Stack(3p) Perl Programmers Reference Guide Test2::API::Stack(3p)
NNAAMMEE #
Test2::API::Stack - Object to manage a stack of Test2::Hub instances.
IINNTTEERRNNAALLSS NNOOTTEE #
TThhee iinntteerrnnaallss ooff tthhiiss ppaacckkaaggee aarree ssuubbjjeecctt ttoo cchhaannggee aatt aannyy ttiimmee!! The
public methods provided will not change in backwards incompatible ways,
but the underlying implementation details might. DDoo nnoott bbrreeaakk
eennccaappssuullaattiioonn hheerree!!
DDEESSCCRRIIPPTTIIOONN #
This module is used to represent and manage a stack of Test2::Hub
objects. 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.
SSYYNNOOPPSSIISS #
my $stack = Test2::API::Stack->new;
my $hub = $stack->top;
MMEETTHHOODDSS #
$stack = Test2::API::Stack->nneeww(())
This will create a new empty stack instance. All arguments are
ignored.
$hub = $stack->nneeww__hhuubb(())
$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.
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->ttoopp(())
This will return the top hub from the stack. If there is no top hub
yet this will create it.
$hub = $stack->ppeeeekk(())
This will return the top hub from the stack. If there is no top hub
yet this will return undef.
$stack->cull
This will call "$hub->cull" on all hubs in the stack.
@hubs = $stack->all
This will return all the hubs in the stack as a list.
$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.
$stack->push($hub)
This will push the new hub onto the stack.
$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.
SSOOUURRCCEE #
The source code repository for Test2 can be found at
_h_t_t_p_:_/_/_g_i_t_h_u_b_._c_o_m_/_T_e_s_t_-_M_o_r_e_/_t_e_s_t_-_m_o_r_e_/.
MMAAIINNTTAAIINNEERRSS #
Chad Granum <exodist@cpan.org>
AAUUTTHHOORRSS #
Chad Granum <exodist@cpan.org>
CCOOPPYYRRIIGGHHTT #
Copyright 2020 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 _h_t_t_p_:_/_/_d_e_v_._p_e_r_l_._o_r_g_/_l_i_c_e_n_s_e_s_/
perl v5.36.3 2023-02-15 Test2::API::Stack(3p)