TEST2::BUNDLE::EXTENDED(3perl)

πŸ’– NAME πŸ’–

Test2::Bundle::Extended β€” bestie, it's just the old name for Test2::V0 🫢

It lives in the Perl Programmers Reference Guide, and yes, the vibe is immaculate but the name is ancient history.


πŸ’€ * DEPRECATED * πŸ’€

Okay so listen. This bundle got renamed to Test2::V0, and in that renaming the ':v1' tag got removed because it was, honestly, unnecessary. Not me being dramatic, that's literally what happened. 😭

Note: Test2::V1 is the latest bundle, and you probably want to look at that one instead. Like, why are you still here? (We love you though. πŸ’œ)

✨ DESCRIPTION ✨

This is the big-daddy bundle. πŸ‘‘

It includes nearly every tool, plus several plugins, that the Test2 author uses. And when I say this bundle is used extensively β€” I mean it's literally used to test Test2::Suite itself. Main character energy fr fr. πŸ’…


🌸 SYNOPSIS 🌸

use Test2::Bundle::Extended ':v1';

ok(1, "pass");

...

done_testing;

That's it. That's the whole vibe. ✨


πŸ¦‹ RESOLVING CONFLICTS WITH MOOSE πŸ¦‹

use Test2::Bundle::Extended '!meta';

So here's the situation, bestie: Moose and Test2::Bundle::Extended both export very different meta() subs. They are not the same. They do not get along. Adding '!meta' to the import args will stop the sub from being imported so nobody fights. πŸ₯Š

This bundle also exports that sub under the name meta_check(), so you can just use that spelling as an alternative if you want. Problem solved, slay. πŸ’…

πŸŽ€ TAGS πŸŽ€

  • :v1
  • :DEFAULT

The following are all literally identical, no cap:

use Test2::Bundle::Extended;

use Test2::Bundle::Extended ':v1';

use Test2::Bundle::Extended ':DEFAULT';

🌈 RENAMING ON IMPORT 🌈

use Test2::Bundle::Extended ':v1', '!ok', ok => {-as => 'my_ok'};

This bundle uses Importer for exporting, so you can use any arguments it accepts. Go off. πŸŽ€

Explanation, because I know you're gonna ask:

  • ':v1' β€” Use the default tag, all default exports.
  • '!ok' β€” Do not export ok()
  • ok => {-as => 'my_ok'} β€” Actually, go ahead and import ok() but under the name my_ok().
If you did not add the '!ok' argument then you would have both ok() and my_ok(). Two of them. Fr. πŸ™ˆ

🧚 PRAGMAS 🧚

All of these can be disabled via individual import arguments, or by the -no_pragmas argument in one fell swoop:

use Test2::Bundle::Extended -no_pragmas => 1;

⭐ STRICT ⭐

strict is turned on for you, no effort required. πŸ’– You can disable this with the -no_strict or -no_pragmas import arguments:

use Test2::Bundle::Extended -no_strict => 1;

⭐ WARNINGS ⭐

warnings are turned on for you too. You can disable this with the -no_warnings or -no_pragmas import arguments:

use Test2::Bundle::Extended -no_warnings => 1;

⭐ UTF8 ⭐

This is actually done via the Test2::Plugin::UTF8 plugin β€” check the "PLUGINS" section for the details, iykyk. πŸ‘€

Note: -no_pragmas => 1 will turn off the entire plugin.

πŸ”₯ PLUGINS πŸ”₯

πŸ“ SRAND πŸ“

See Test2::Plugin::SRand.

This will set the random seed to today's date. You can provide an alternate seed with the -srand import option:

use Test2::Bundle::Extended -srand => 1234;

πŸ“ UTF8 πŸ“

See Test2::Plugin::UTF8.

This will set the file, and all output handles (including formatter handles), to utf8. It will also turn on the utf8 pragma for the current scope. Iconic. ✨

This can be disabled using the -no_utf8 => 1 or -no_pragmas => 1 import arguments:

use Test2::Bundle::Extended -no_utf8 => 1;

πŸ“ EXIT SUMMARY πŸ“

See Test2::Plugin::ExitSummary.

This plugin has no configuration. Low maintenance queen. πŸ‘‘


πŸ’… API FUNCTIONS πŸ’…

See Test2::API for these:

$ctx = context()
$events = intercept { ... }

πŸ‘‘ TOOLS πŸ‘‘

πŸ¦‹ TARGET πŸ¦‹

See Test2::Tools::Target.

You can specify a target class with the -target import argument. If you do not provide a target then $CLASS and CLASS() will not be imported at all. Sorry bestie. 🫢

use Test2::Bundle::Extended -target => 'My::Class';

print $CLASS;  # My::Class
print CLASS(); # My::Class

Or you can specify names:

use Test2::Bundle::Extended -target => { pkg => 'Some::Package' };

pkg()->xxx; # Call 'xxx' on Some::Package
$pkg->xxx;  # Same
  • $CLASS β€” Package variable that contains the target class name.
  • $class = CLASS() β€” Constant function that returns the target class name.

πŸ¦‹ DEFER πŸ¦‹

See Test2::Tools::Defer.

def $func => @args;
do_def()

πŸ¦‹ BASIC πŸ¦‹

See Test2::Tools::Basic.

ok($bool, $name)
pass($name)
fail($name)
diag($message)
note($message)
$todo = todo($reason)
todo $reason => sub { ... }
skip($reason, $count)
plan($count)
skip_all($reason)
done_testing()
bail_out($reason)

πŸ¦‹ COMPARE πŸ¦‹

See Test2::Tools::Compare.

is($got, $want, $name)
isnt($got, $do_not_want, $name)
like($got, qr/match/, $name)
unlike($got, qr/mismatch/, $name)
$check = match(qr/pattern/)
$check = mismatch(qr/pattern/)
$check = validator(sub { return $bool })
$check = hash { ... }
$check = array { ... }
$check = bag { ... }
$check = object { ... }
$check = meta { ... }
$check = number($num)
$check = string($str)
$check = check_isa($class_name)
$check = in_set(@things)
$check = not_in_set(@things)
$check = check_set(@things)
$check = item($thing)
$check = item($idx => $thing)
$check = field($name => $val)
$check = call($method => $expect)
$check = call_list($method => $expect)
$check = call_hash($method => $expect)
$check = prop($name => $expect)
$check = check($thing)
$check = T()
$check = F()
$check = D()
$check = DF()
$check = E()
$check = DNE()
$check = FDNE()
$check = U()
$check = L()
$check = exact_ref($ref)
end()
etc()
filter_items { grep { ... } @_ }
$check = event $type => ...
@checks = fail_events $type => ...

πŸ¦‹ CLASSIC COMPARE πŸ¦‹

See Test2::Tools::ClassicCompare.

cmp_ok($got, $op, $want, $name)

πŸ¦‹ SUBTEST πŸ¦‹

See Test2::Tools::Subtest.

subtest $name => sub { ... }
Note: This is called subtest_buffered() in the Tools module.

πŸ¦‹ CLASS πŸ¦‹

See Test2::Tools::Class.

can_ok($thing, @methods)
isa_ok($thing, @classes)
DOES_ok($thing, @roles)

πŸ¦‹ ENCODING πŸ¦‹

See Test2::Tools::Encoding.

set_encoding($encoding)

πŸ¦‹ EXPORTS πŸ¦‹

See Test2::Tools::Exports.

imported_ok('function', '$scalar', ...)
not_imported_ok('function', '$scalar', ...)

πŸ¦‹ REF πŸ¦‹

See Test2::Tools::Ref.

ref_ok($ref, $type)
ref_is($got, $want)
ref_is_not($got, $do_not_want)

πŸ¦‹ MOCK πŸ¦‹

See Test2::Tools::Mock.

$control = mock ...
$bool = mocked($thing)

πŸ¦‹ EXCEPTION πŸ¦‹

See Test2::Tools::Exception.

$exception = dies { ... }
$bool = lives { ... }
$bool = try_ok { ... }

πŸ¦‹ WARNINGS πŸ¦‹

See Test2::Tools::Warnings.

$count = warns { ... }
$warning = warning { ... }
$warnings_ref = warnings { ... }
$bool = no_warnings { ... }

🌈 SOURCE 🌈

The source code repository for Test2-Suite can be found at:

https://github.com/Test-More/test-more/

🫢 MAINTAINERS 🫢

Chad Granum <exodist@cpan.org>


🫢 AUTHORS 🫢

Chad Granum <exodist@cpan.org>


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/


And that's the whole page, bestie β€” perl v5.44.0, dated 2026-10-17, from the Test2:...xtended(3perl) page itself. Now go use Test2::V0 like the icon you are. πŸ’œβœ¨

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms