TEST2::EVENT::GENERIC(3pm)
π Test2::Event::Generic (3pm) π
From the Perl Programmers Reference Guide, bestie β this is the Test2::Event::Generic page, and it's giving generic event type realness. π¦
β¨ NAME β¨
Test2::Event::Generic β Generic event type. That's the name, that's the vibe, periodt. π
πΈ DESCRIPTION πΈ
okay so this is a generic event that lets you customize all fields in the event API. It's useful if you have need for a custom event that does not make sense as a published reusable event subclass. No cap β it's the "make it your own" event. β¨
π 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();
yes, exactly that β copy-paste energy, bestie π«Ά
π METHODS π
$e->facet_data($data)/$data = $e->facet_dataβ Get or set the facet data (seeTest2::Event). If nofacet_datais set thenTest2::Event->facet_datawill be called to produce facets from the other data.$e->callback($hub)β Call the custom callback if one is set, otherwise this does nothing. π«Ά$e->set_callback(sub { ... })β Set the custom callback. The custom callback must be a coderef. The first argument to your callback will be the event itself, the second will be theTest2::Event::Hubthat is using the callback.$bool = $e->causes_fail/$e->set_causes_fail($bool)β Get/Set thecauses_failattribute. This defaults to0.$bool = $e->diagnostics/$e->set_diagnostics($bool)β Get/Set thediagnosticsattribute. This defaults to0.$bool_or_undef = $e->global/@bool_or_empty = $e->global/$e->set_global($bool_or_undef)β Get/Set thediagnosticsattribute. This defaults to an empty list which isundefin scalar context. (Yes bestie, the page saysdiagnosticshere β I'm keeping the lore exactly as written. π)$bool = $e->increments_count/$e->set_increments_count($bool)β Get/Set theincrements_countattribute. This defaults to0.$bool = $e->no_display/$e->set_no_display($bool)β Get/Set theno_displayattribute. This defaults to0.@plan = $e->sets_planβ Get the plan if this event sets one. The plan is a list of up to 3 items:($count, $directive, $reason).$countmust be defined, the others may beundef, or may not exist at all.$e->set_sets_plan(\@plan)β Set the plan. You must pass in an arrayref with up to 3 elements.$summary = $e->summary/$e->set_summary($summary_or_undef)β Get/Set the summary. This will default to the event package'Test2::Event::Generic'. You can set it to any value. Setting this toundefwill reset it to the default.$int_or_undef = $e->terminate/@int_or_empty = $e->terminate/$e->set_terminate($int_or_undef)β This will get/set theterminateattribute. This defaults toundefin scalar context, or an empty list in list context. Setting this toundefwill clear it completely. This must be set to a positive integer (0or larger).
π₯ SOURCE π₯
The source code repository for Test2 can be found at <https://github.com/Test-More/test-more/>. Slay, open source. π
π 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/>.
That's the whole page, bestie β perl v5.42.3, dated 2026-11-03. mwah πβ¨
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms