Scroll to navigation

Test2::Handle(3) User Contributed Perl Documentation Test2::Handle(3)

NAME

Test2::Handle - Base class for Test2 handles used in V# bundles.

DESCRIPTION

This is what you interact with when you use the T2() function in a test that uses Test2::V1.

SYNOPSIS

    use Test2::V1;
    my $handle = T2();
    $handle->ok(1, "Passing Test");

WITHOUT SUGAR

    use Test2::Handle();
    my $handle = Test2::Handle->new(base => 'Test2::V1::Base');
    $handle->ok(1, "Passing test");

METHODS

Most methods are delegated to the base class provided at construction. There are however a few methods that are defined by this package itself.

$base = $class_or_inst->DEFAULT_HANDLE_BASE
Get the default handle base. This throws an exception on the base handle class, you should override it in a subclass.
$base = $inst->HANDLE_BASE
In this base class this method always throws an exception. In a subclass it should return the default base class to use for that subclass.
$namespace = $inst->HANDLE_NAMESPACE
Get the namespace used to store function we wrap as methods.
@sub_names = $inst->HANDLE_SUBS
Get a list of all subs available in the handle namespace.
$inst->HANDLE_INCLUDE($package, @subs)
Import the specified subs from the specified package into our internal namespace.
$inst = $class->import()
Used to create a T2() sub in your namsepace at import.
$inst->init()
Internally used to intialize and validate the handle object.
Internally used to wrap functions as methods.

SOURCE

The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/.

MAINTAINERS

AUTHORS

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 http://dev.perl.org/licenses/

2025-12-10 perl v5.42.0