Test2::Handle(3perl)

Test2::Handle3perl

Base class for test2 handles used in v# bundles.

Usage

Recommended

    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");

Overview

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

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.

AUTOLOAD

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

Chad Granum <[email protected]>

Authors

Chad Granum <[email protected]>

From perl 5.44.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.