Test2:...Legacy(3perl)
π Test2::Util::Facets2Legacy β the manual, but make it make sense
okay bestie, so this page is Test2:...Legacy(3perl) from the Perl Programmers Reference Guide and it's all about Test2::Util::Facets2Legacy β the glow-up module that turns facet data into the legacy event API. no cap, it's shorter than it looks. let's go β¨
π¦ NAME
Test2::Util::Facets2Legacy β the little translator that converts facet data into the legacy event API. iykyk π
πΈ DESCRIPTION
So this module exports several subroutines from the older event API (peep Test2::Event if you wanna see where they come from, bestie).
Here's the tea: you can use these subroutines as methods on literally any object that provides a custom facet_data() method. π«Ά
You can also use them as functions that just take a facet data hashref as their argument. two vibes, one module. iconic.
β¨ SYNOPSIS
π AS METHODS
package My::Event;
use Test2::Util::Facets2Legacy ':ALL';
sub facet_data { return { ... } }
Then to use it:
my $e = My::Event->new(...);
my $causes_fail = $e->causes_fail;
my $summary = $e->summary;
....
π AS FUNCTIONS
use Test2::Util::Facets2Legacy ':ALL';
my $f = {
assert => { ... },
info => [{...}, ...],
control => {...},
...
};
my $causes_fail = causes_fail($f);
my $summary = summary($f);
π NOTE ON CYCLES
okay so this is the part where you need to pay attention, bestie, because it's giving danger.
When you use these as methods, all these subroutines call $e->facet_data(). Meanwhile, the default facet_data() method in Test2::Event relies on the legacy methods this module emulates in order to work.
soβ¦ yeah. as a result of that lil ouroboros situation, it is very easy to create infinite recursion bugs. π
Good news tho: these methods have cycle detection and will throw an exception early if a cycle is detected. and get this β uuid() is currently the only subroutine in this library that has a fallback behavior when cycles are detected. main character energy, honestly. π
β οΈ fr fr, don't fight the cycle detection. it's there for a reason.
π EXPORTS
Nothing is exported by default. You must specify which methods to import, or use the ':ALL' tag. that's the whole deal, babe.
$bool = $e->causes_fail()$bool = causes_fail($f)β Check if the event or facets result in a failing state.$bool = $e->diagnostics()$bool = diagnostics($f)β Check if the event or facets contain any diagnostics information.$bool = $e->global()$bool = global($f)β Check if the event or facets need to be globally processed.$bool = $e->increments_count()$bool = increments_count($f)β Check if the event or facets make an assertion.$bool = $e->no_display()$bool = no_display($f)β Check if the event or facets should be rendered or hidden.($max, $directive, $reason) = $e->sets_plan()($max, $directive, $reason) = sets_plan($f)β Check if the event or facets set a plan, and return the plan details.$id = $e->subtest_id()$id = subtest_id($f)β Get the subtest id, if any.$string = $e->summary()$string = summary($f)β Get the summary of the event or facets hash, if any.$undef_or_int = $e->terminate()$undef_or_int = terminate($f)β Check if the event or facets should result in process termination, if so the exit code is returned (which could be0).undefis returned if no termination is requested.$uuid = $e->uuid()$uuid = uuid($f)β Get the UUID of the facets or event.
Note: This will fall back to "$e->SUPER::uuid()" if a cycle is detected and an event is used as the argument. π§
π SOURCE
The source code repository for Test2 can be found at <https://github.com/Test-More/test-more/>.
go star it, it's free π
π 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!! slay!! πβ¨
this was perl v5.44.0, from 2026-10-17, filed under Test2:...Legacy(3perl). mwah, go read Test2::Event next π
π¦
π¦ 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