1Test2::Util::Facets2LegUasceyr(3C)ontributed Perl DocumeTnetsatt2i:o:nUtil::Facets2Legacy(3)
2
3
4

NAME

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

DESCRIPTION

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

SYNOPSIS

16   AS METHODS
17           package My::Event;
18
19           use Test2::Util::Facets2Legacy ':ALL';
20
21           sub facet_data { return { ... } }
22
23       Then to use it:
24
25           my $e = My::Event->new(...);
26
27           my $causes_fail = $e->causes_fail;
28           my $summary     = $e->summary;
29           ....
30
31   AS FUNCTIONS
32           use Test2::Util::Facets2Legacy ':ALL';
33
34           my $f = {
35               assert => { ... },
36               info => [{...}, ...],
37               control => {...},
38               ...
39           };
40
41           my $causes_fail = causes_fail($f);
42           my $summary     = summary($f);
43

NOTE ON CYCLES

45       When used as methods, all these subroutines call "$e->facet_data()".
46       The default "facet_data()" method in Test2::Event relies on the legacy
47       methods this module emulates in order to work. As a result of this it
48       is very easy to create infinite recursion bugs.
49
50       These methods have cycle detection and will throw an exception early if
51       a cycle is detected. "uuid()" is currently the only subroutine in this
52       library that has a fallback behavior when cycles are detected.
53

EXPORTS

55       Nothing is exported by default. You must specify which methods to
56       import, or use the ':ALL' tag.
57
58       $bool = $e->causes_fail()
59       $bool = causes_fail($f)
60           Check if the event or facets result in a failing state.
61
62       $bool = $e->diagnostics()
63       $bool = diagnostics($f)
64           Check if the event or facets contain any diagnostics information.
65
66       $bool = $e->global()
67       $bool = global($f)
68           Check if the event or facets need to be globally processed.
69
70       $bool = $e->increments_count()
71       $bool = increments_count($f)
72           Check if the event or facets make an assertion.
73
74       $bool = $e->no_display()
75       $bool = no_display($f)
76           Check if the event or facets should be rendered or hidden.
77
78       ($max, $directive, $reason) = $e->sets_plan()
79       ($max, $directive, $reason) = sets_plan($f)
80           Check if the event or facets set a plan, and return the plan
81           details.
82
83       $id = $e->subtest_id()
84       $id = subtest_id($f)
85           Get the subtest id, if any.
86
87       $string = $e->summary()
88       $string = summary($f)
89           Get the summary of the event or facets hash, if any.
90
91       $undef_or_int = $e->terminate()
92       $undef_or_int = terminate($f)
93           Check if the event or facets should result in process termination,
94           if so the exit code is returned (which could be 0). undef is
95           returned if no termination is requested.
96
97       $uuid = $e->uuid()
98       $uuid = uuid($f)
99           Get the UUID of the facets or event.
100
101           Note: This will fall back to "$e->SUPER::uuid()" if a cycle is
102           detected and an event is used as the argument.
103

SOURCE

105       The source code repository for Test2 can be found at
106       http://github.com/Test-More/test-more/.
107

MAINTAINERS

109       Chad Granum <exodist@cpan.org>
110

AUTHORS

112       Chad Granum <exodist@cpan.org>
113
115       Copyright 2018 Chad Granum <exodist@cpan.org>.
116
117       This program is free software; you can redistribute it and/or modify it
118       under the same terms as Perl itself.
119
120       See http://dev.perl.org/licenses/
121
122
123
124perl v5.26.3                      2018-03-30     Test2::Util::Facets2Legacy(3)
Impressum