Test2::...2Legacy(3pm)
πΈ NAME πΈ
Test2::Util::Facets2Legacy β Convert facet data to the legacy event API.
okay so this is the Test2::...2Legacy(3pm) page from the Perl Programmers Reference Guide, and itβs all about turning facet data into the older event API vibes. π
π DESCRIPTION π
This module exports several subroutines from the older event API β see Test2::Event for the lore.
These subroutines can be used as methods on any object that provides a custom facet_data() method. They can also be used as functions that take a facet data hashref as arguments. Versatile queen behavior, honestly. β¨
π 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 π
Bestie, listen. When used as methods, all these subroutines call $e->facet_data().
The default facet_data() method in Test2::Event relies on the legacy methods this module emulates in order to work. As a result of this, it is very easy to create infinite recursion bugs. π
These methods have cycle detection and will throw an exception early if a cycle is detected. uuid() is currently the only subroutine in this library that has a fallback behavior when cycles are detected. So likeβ¦ be careful, but also slay. π«Ά
β¨ EXPORTS β¨
Nothing is exported by default. You must specify which methods to import, or use the ':ALL' tag. Periodt. π
$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 be 0).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 touch grass in the repo, bestie. π±
π 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/>
xoxo, this cutie of a page is from 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