1Test2::API::Stack(3)  User Contributed Perl Documentation Test2::API::Stack(3)
2
3
4

NAME

6       Test2::API::Stack - Object to manage a stack of Test2::Hub instances.
7

***INTERNALS NOTE***

9       The internals of this package are subject to change at any time! The
10       public methods provided will not change in backwards incompatible ways,
11       but the underlying implementation details might. Do not break
12       encapsulation here!
13

DESCRIPTION

15       This module is used to represent and manage a stack of Test2::Hub
16       objects. Hubs are usually in a stack so that you can push a new hub
17       into place that can intercept and handle events differently than the
18       primary hub.
19

SYNOPSIS

21           my $stack = Test2::API::Stack->new;
22           my $hub = $stack->top;
23

METHODS

25       $stack = Test2::API::Stack->new()
26           This will create a new empty stack instance. All arguments are
27           ignored.
28
29       $hub = $stack->new_hub()
30       $hub = $stack->new_hub(%params)
31       $hub = $stack->new_hub(%params, class => $class)
32           This will generate a new hub and push it to the top of the stack.
33           Optionally you can provide arguments that will be passed into the
34           constructor for the Test2::Hub object.
35
36           If you specify the "'class' => $class" argument, the new hub will
37           be an instance of the specified class.
38
39           Unless your parameters specify 'formatter' or 'ipc' arguments, the
40           formatter and IPC instance will be inherited from the current top
41           hub. You can set the parameters to "undef" to avoid having a
42           formatter or IPC instance.
43
44           If there is no top hub, and you do not ask to leave IPC and
45           formatter undef, then a new formatter will be created, and the IPC
46           instance from Test2::API will be used.
47
48       $hub = $stack->top()
49           This will return the top hub from the stack. If there is no top hub
50           yet this will create it.
51
52       $hub = $stack->peek()
53           This will return the top hub from the stack. If there is no top hub
54           yet this will return undef.
55
56       $stack->cull
57           This will call "$hub->cull" on all hubs in the stack.
58
59       @hubs = $stack->all
60           This will return all the hubs in the stack as a list.
61
62       $stack->clear
63           This will completely remove all hubs from the stack. Normally you
64           do not want to do this, but there are a few valid reasons for it.
65
66       $stack->push($hub)
67           This will push the new hub onto the stack.
68
69       $stack->pop($hub)
70           This will pop a hub from the stack, if the hub at the top of the
71           stack does not match the hub you expect (passed in as an argument)
72           it will throw an exception.
73

SOURCE

75       The source code repository for Test2 can be found at
76       http://github.com/Test-More/test-more/.
77

MAINTAINERS

79       Chad Granum <exodist@cpan.org>
80

AUTHORS

82       Chad Granum <exodist@cpan.org>
83
85       Copyright 2020 Chad Granum <exodist@cpan.org>.
86
87       This program is free software; you can redistribute it and/or modify it
88       under the same terms as Perl itself.
89
90       See http://dev.perl.org/licenses/
91
92
93
94perl v5.32.0                      2020-10-15              Test2::API::Stack(3)
Impressum