Test2::Util::Facets2Legacy(3) User Contributed Perl Documentation Test2::Util::Facets2Legacy(3)

# [NAME](#NAME)

Test2::Util::Facets2Legacy - Convert facet data to the legacy event API.

# [DESCRIPTION](#DESCRIPTION)

This module exports several subroutines from the older event API (see Test2::Event). These subroutines can be used as methods on any object that provides a custom facet\_data() method. These subroutines can also be used as functions that take a facet data hashref as arguments.

# [SYNOPSIS](#SYNOPSIS)

## [AS METHODS](#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](#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](#NOTE_ON_CYCLES)

When used as methods, all these subroutines call "$e-&gt;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.

# [EXPORTS](#EXPORTS)

Nothing is exported by default. You must specify which methods to import, or use the ':ALL' tag.

$bool = $e-&gt;**causes\_fail()**

$bool = causes\_fail($f)

Check if the event or facets result in a failing state.

$bool = $e-&gt;**diagnostics()**

$bool = diagnostics($f)

Check if the event or facets contain any diagnostics information.

$bool = $e-&gt;**global()**

$bool = global($f)

Check if the event or facets need to be globally processed.

$bool = $e-&gt;**increments\_count()**

$bool = increments\_count($f)

Check if the event or facets make an assertion.

$bool = $e-&gt;**no\_display()**

$bool = no\_display($f)

Check if the event or facets should be rendered or hidden.

($max, $directive, $reason) = $e-&gt;**sets\_plan()**

($max, $directive, $reason) = sets\_plan($f)

Check if the event or facets set a plan, and return the plan details.

$id = $e-&gt;**subtest\_id()**

$id = subtest\_id($f)

Get the subtest id, if any.

$string = $e-&gt;**summary()**

$string = summary($f)

Get the summary of the event or facets hash, if any.

$undef\_or\_int = $e-&gt;**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). undef is returned if no termination is requested.

$uuid = $e-&gt;**uuid()**

$uuid = uuid($f)

Get the UUID of the facets or event.

**Note:** This will fall back to "$e-&gt;SUPER::uuid()" if a cycle is detected and an event is used as the argument.

# [SOURCE](#SOURCE)

The source code repository for Test2 can be found at &lt;https://github.com/Test-More/test-more/&gt;.

# [MAINTAINERS](#MAINTAINERS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad)

# [AUTHORS](#AUTHORS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad~2)

# [COPYRIGHT](#COPYRIGHT)

Copyright Chad Granum &lt;exodist@cpan.org&gt;.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See &lt;https://dev.perl.org/licenses/&gt;

2026-10-26 perl v5.44.0

---

Document: Test2::Util::Facets2Legacy(3pm) from perl-test-simple 1.302226-r2 (Chainguard OS)
Source: https://github.com/Test-More/test-more
