T - Encapsulate testing tools instead of cluttering your namespace.
This module collection makes it possible to use popular testing tools such as Test::More or Test2::Bundle::Extended without cluttering up your namespace. Under the hood all the work is done by Import::Box which was created specifically to implement this.
use T 'More'; # Loads Test::More, and provides the t() box function
use T2 'Basic'; # Loads Test2::Tools::Basic, and provides the t2() function
use T2::B 'Extended'; # Loads Test2::Bundle::Extended, also provides/appends to the t2() function
use T2::P 'SRand'; # Loads Test2::Plugin::SRand, and provides the t2p() function
t->is('a', 'a', "Can run Test::More::is()");
t2->is('a', 'a', "Can run Test2::Tools::Compare::is()"); # (Provided by the extended bundle)
# Alternate syntax:
t is => ('a', 'a');
t2 is => ('a', 'a');
use T;
use T2;
use T2::B;
my $t = T->new('More'); # Loads Test::More into $t
my $t2 = T2->new('Basic'); # Loads Test2::Tools::Basic into $t2
my $t2b = T2::B->new('Extended'); # Loads Test2::Bundle::Extended into $t2b
$t->is('a', 'a', "Can run Test::More::is()");
$t2->ok(1, "ok from Test2::Tools::Basic");
$t2b->is('a', 'a', "Can run Test2::Tools::Compare::is()");
# Indirect syntax (just say NO!)
is $t('a', 'a');
ok $t2(1, "pass");
is $t2b('a', 'a');
-
T
This is used for boxing
Test::
modules into thet()
box. -
T2
This is used for boxing
Test2::Tools::
modules into thet2()
box. -
T2::B
This is used for boxing
Test2::Bundle::
modules into thet2()
box. -
T2::P
This is used for boxing
Test2::Plugin::
modules into thet2p()
box. A plugin should never actually export anything, so this is actually just a shortcut for loading plugins.
-
t->import($MODULE)
-
$t->import($MODULE)
-
t->import($MODULE => \@IMPORT_ARGS)
-
$t->import($MODULE => \@IMPORT_ARGS)
This will load
$MODULE
and place the exports into the box instead of your namespace. A prefix is automatically prepended to$MODULE
, which prefix depends on the class used for boxing. To avoid the prefix you can append '+' to the front of$MODULE
:t->import('+My::Module');
Import::Box - Everything here is based off of this module.
The source code repository for T can be found at
http://github.com/Test-More/T/
.
- Chad Granum exodist@cpan.org
- Chad Granum exodist@cpan.org
Copyright 2016 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/