TEST2::EVENT::V2(3perl)
π Test2::Event::V2 β the perl pragma doc, but make it cute π
okay bestie, this is the page from the Perl Programmers Reference Guide for Test2::Event::V2, and it's genuinely one of my faves so let's get into it β¨
πΈ NAME πΈ
Test2::Event::V2 β the second generation event. glow-up event, fr fr π
π¦ DESCRIPTION π¦
so like, THIS is the event type you should be using. not Test2::Event, not its legacy subclasses β those are giving "hand-me-down", and this is giving main character energy. use this one instead. periodt π
β¨ SYNOPSIS β¨
π USING A CONTEXT
use Test2::API qw/context/;
sub my_tool {
my $ctx = context();
my $event = $ctx->send_ev2(info => [{tag => 'NOTE', details => "This is a note"}]);
$ctx->release;
return $event;
}
π USING THE CONSTRUCTOR
use Test2::Event::V2;
my $e = Test2::Event::V2->new(
trace => {frame => [$PKG, $FILE, $LINE, $SUBNAME]},
info => [{tag => 'NOTE', details => "This is a note"}],
);
π METHODS π
heads up: this class inherits from Test2::Event. we're building on the family legacy π
$fd = $e->facet_data()β hands you back a hashref of facet data. every facet hash in there is a shallow copy of the original, so you can't mess with the real ones by accident. respectful king behavior π«Ά$about = $e->about()β gives you the'about'facet hashref.
β οΈ NOTE: this gives you the internal hashref, NOT a copy. so like, pls be careful with it bestie π
$trace = $e->trace()β gives you the'trace'facet, which is normally blessed (but that's not enforced when the trace gets set usingset_trace()).
β οΈ NOTE: again, this is the internal trace, not a copy. literally the same warning, different facet π
π₯ MUTATION
$e->add_amnesty({...})β inherited fromTest2::Event. you use this to add'amnesty'facets onto an event that already exists. each new item goes onto the END of the list.
π NOTE: items ARE blessed when they get added. fancy.
$e->add_hub({...})β inherited fromTest2::Event. hubs use this to stamp events as they pass through. new items go onto the START of the list (yes, the opposite of the one above, stay woke π).
π NOTE: items ARE NOT blessed when they get added. no fancy for these ones.
$e->set_uuid($UUID)β inherited fromTest2::Event, but overridden here so it also vivifies/mutates the'about'facet. multitasking icon β$e->set_trace($trace)β inherited fromTest2::Event, lets you swap out the trace.
β οΈ Note: this method does not bless/clone the trace for you. and a LOT of stuff out there expects the trace to be blessed, so likeβ¦ you should probably do that yourself. not me having to tell you twice π
π LEGACY SUPPORT METHODS
every single one of these is imported from Test2::Util::Facets2Legacy β go read that module or Test2::Event if you wanna know what they actually do, i'm not unlocking that lore here π
causes_faildiagnosticsglobalincrements_countno_displaysets_plansubtest_idsummaryterminate
π§ THIRD PARTY META-DATA π§
this object consumes Test2::Util::ExternalMeta, which gives you a consistent way to attach meta-data onto instances of this class. super useful if you're out here building tools, plugins, and other extensions β it's giving pluggable β¨
πΈ SOURCE πΈ
the source code repo for Test2 lives at https://github.com/Test-More/test-more/ β go be nosy, it's fine π
π 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, no cap π«Ά this was perl v5.44.0, dated 2026-10-17, from Test2::Event::V2(3perl). slay, go write some events πβ¨π
π¦ 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