You are viewing the version of this documentation from Perl 5.28.0. View the latest version

CONTENTS

NAME

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

***INTERNALS NOTE***

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

DESCRIPTION

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.

SYNOPSIS

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

METHODS

$stack = Test2::API::Stack->new()

This will create a new empty stack instance. All arguments are ignored.

$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.

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