TEST2::EVENT::GENERIC(3perl)
π Test2::Event::Generic β the perl manpage, but make it cute β¨
okay so bestie, welcome to Test2::Event::Generic(3perl), straight out of the Perl Programmers Reference Guide πΈ and literally it's the generic event of your dreams. let's get into it π
β¨ NAME β¨
Test2::Event::Generic β it's a generic event type, and it's giving blank canvas π¨
π DESCRIPTION π
so this is a generic event that lets you customize every single field in the event API. not most of them. not some of them. all of them. π
when is that useful? when you need a custom event that lowkey doesn't make sense as a published reusable event subclass. like, it's a one-off vibe, not a whole family legacy. and that's valid π«Ά
π SYNOPSIS π
use Test2::API qw/context/;
sub send_custom_fail {
my $ctx = shift;
$ctx->send_event('Generic', causes_fail => 1, summary => 'The sky is falling');
$ctx->release;
}
send_custom_fail();
not the 'The sky is falling' summary π iconic behavior honestly.
π¦ METHODS π¦
$e->facet_data($data)$data = $e->facet_data
get it or set it, your call bestie π this is the facet data (peep Test2::Event for the lore). and if no facet_data is set? then Test2::Event->facet_data gets called to produce facets from the other data. no facet data, no problem, it'll cook π
$e->callback($hub)
calls the custom callback if one is set. if there isn't one? literally nothing happens. it does nothing. silent. respectful. π
$e->set_callback(sub { ... })
sets the custom callback. β οΈ the custom callback must be a coderef. first arg you get is the event itself, second arg is the Test2::Hub that's using the callback. two lil presents π
$bool = $e->causes_fail$e->set_causes_fail($bool)
get/set the causes_fail attribute. default is 0. periodt π
$bool = $e->diagnostics$e->set_diagnostics($bool)
get/set the diagnostics attribute. defaults to 0. π©Ί
$bool_or_undef = $e->global@bool_or_empty = $e->global$e->set_global($bool_or_undef)
get/set the "diagnostics" attribute β yes bestie, that's literally what it says, iykyk π β and it defaults to an empty list, which reads as undef in scalar context. context is everything, fr fr.
$bool = $e->increments_count$e->set_increments_count($bool)
get/set the increments_count attribute. default? you guessed it: 0. π’
$bool = $e->no_display$e->set_no_display($bool)
get/set the no_display attribute. defaults to 0. π
@plan = $e->sets_plan
grab the plan if this event sets one ποΈ the plan is a list of up to 3 items: ($count, $directive, $reason). $count must be defined β no debate β but the others may be undef, or may not exist at all. they can simply not show up. ghosting is allowed here π»
$e->set_sets_plan(\@plan)
set the plan. you must pass in an arrayref with up to 3 elements. up to three. not four. π«
$summary = $e->summary$e->set_summary($summary_or_undef)
get/set the summary. it defaults to the event package 'Test2::Event::Generic'. you can set it to literally any value π« and if you set it to undef, it resets right back to the default. undo button, but make it slay.
$int_or_undef = $e->terminate@int_or_empty = $e->terminate$e->set_terminate($int_or_undef)
this gets/sets the terminate attribute. defaults to undef in scalar context, or an empty list in list context. setting it to undef clears it completely. π§Ό and β οΈ heads up: this must be set to a positive integer (0 or larger). zero counts. negative does not. no cap.
π SOURCE π
the source code repository for Test2 lives at <https://github.com/Test-More/test-more/> β go peek, it's right there π«Ά
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
π 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 <https://dev.perl.org/licenses/>
and that's the whole page bestie!! π this was perl v5.44.0, dated 2026-10-17, and the manual name is Test2:...Generic(3perl) if you need to cite your sources π
mwah, go write a generic event, you're gonna eat π₯ β¨
π¦ 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