Test2::Util::Facets2Legacy - Convert facet data to the legacy event API. |
Test2::Util::Facets2Legacy - Convert facet data to the legacy event API.
This module exports several subroutines from the older event API (see
the Test2::Event manpage). 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.
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; ....
use Test2::Util::Facets2Legacy ':ALL';
my $f = { assert => { ... }, info => [{...}, ...], control => {...}, ... };
my $causes_fail = causes_fail($f); my $summary = summary($f);
When used as methods, all these subroutines call $e->facet_data()
. The
default facet_data()
method in the Test2::Event manpage 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.
Nothing is exported by default. You must specify which methods to import, or use the ':ALL' tag.
causes_fail()
causes_fail($f)
diagnostics()
diagnostics($f)
global()
global($f)
increments_count()
increments_count($f)
no_display()
no_display($f)
sets_plan()
sets_plan($f)
subtest_id()
subtest_id($f)
summary()
summary($f)
terminate()
terminate($f)
uuid()
uuid($f)
Note: This will fall back to $e->SUPER::uuid()
if a cycle is
detected and an event is used as the argument.
The source code repository for Test2 can be found at http://github.com/Test-More/test-more/.
Copyright 2019 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 http://dev.perl.org/licenses/
Test2::Util::Facets2Legacy - Convert facet data to the legacy event API. |