TEST2::BUNDLE::EXTENDED(3pm)

πŸ¦‹ Test2::Bundle::Extended β€” a manual page, but make it group chat πŸ¦‹

okay so this is the Test2::Bundle::Extended(3pm) page from the Perl Programmers Reference Guide, and bestie, we need to talk about it because the name is giving vintage and the docs are giving "girl, we renamed this ages ago" πŸ’…


✨ NAME ✨

Test2::Bundle::Extended β€” the old name for Test2::V0. that's it, that's the whole name section πŸŽ€


πŸ’€ *** DEPRECATED *** πŸ’€

so this bundle got a glow-up and now it goes by Test2::V0. the ':v1' tag? gone. removed. deemed unnecessary. she doesn't need it anymore, she's THAT girl now πŸ‘‘βœ¨


🌸 DESCRIPTION 🌸

this is the big-daddy bundle. no like literally the big-daddy one. it includes, like, nearly every single tool plus several plugins that the Test2 author themself actually uses. and it's not just for show β€” this bundle gets used extensively to test Test2::Suite itself. main character energy fr fr πŸ”₯


πŸŽ€ SYNOPSIS πŸŽ€

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

    ok(1, "pass");

    ...

    done_testing;

that's the whole vibe check. ok(1, "pass"), a little ... for ✨drama✨, then done_testing to close it out. slay πŸ’–


🫢 RESOLVING CONFLICTS WITH MOOSE 🫢

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

so here's the tea: Moose and Test2::Bundle::Extended both export meta() subs and they are very different subs. like, not even distant cousins. adding '!meta' to the import args stops that sub from being imported at all. and because this bundle is thoughtful like that, it also exports the sub under the name meta_check() so you can just use that spelling instead if you prefer. options, we love options πŸ¦‹

🏷️ TAGS 🏷️

  • :v1
  • :DEFAULT

the following are all identical, no cap:

    use Test2::Bundle::Extended;

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

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

three ways, one destiny ⭐


πŸ’œ RENAMING ON IMPORT πŸ’œ

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

this bundle uses Importer for exporting, which means you can use any arguments it accepts. very "we're flexible, we're accommodating" of her πŸ’…

Explanation, bestie, 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().

and a lil heads up: if you did not add the '!ok' argument then you would have both ok() and my_ok(). which, awkward. don't do that πŸ™ˆ


🌈 PRAGMAS 🌈

all of these can be disabled via individual import arguments, or by the -no_pragmas argument. one switch, everything off, iconic:

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

πŸ”’ STRICT πŸ”’

strict is turned on for you. it's just there. 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. also just there. you can disable this with the -no_warnings or -no_pragmas import arguments:

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

πŸ’« UTF8 πŸ’«

this one is actually done via the Test2::Plugin::UTF8 plugin (check the "PLUGINS" section below, it's literally right there 🫢).

note: -no_pragmas => 1 will turn off the entire plugin. like, the whole thing. gone. πŸ’€

🧚 PLUGINS 🧚

🎲 SRAND 🎲

see Test2::Plugin::SRand.

this sets the random seed to today's date. cute, right? but you can also provide an alternate seed with the -srand import option:

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

🌟 UTF8 🌟

see Test2::Plugin::UTF8.

this sets the file, and all output handles (including formatter handles) to utf8, and it turns on the utf8 pragma for the current scope. very "everything is beautiful and nothing hurts" of it πŸ’–

you can disable this 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. no options, no settings, no notes. she just does her job and leaves ✨


πŸ› οΈ 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. important!! 🫢

    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. this section is long, hydrate before reading bestie πŸ’§

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

ate. no crumbs. πŸ“

πŸ•°οΈ 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. just so you know πŸ‘€)

πŸ›οΈ 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 lives at https://github.com/Test-More/test-more/. go be nosy, it's encouraged 🫢


πŸ‘€ 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 page bestie πŸ’– brought to you by perl v5.42.3, dated 2026-11-03 β€” same Test2::...Extended(3pm) footer as always, just with way more sparkle this time βœ¨πŸŽ€πŸ’…

πŸ“¦ where this page comes from