Debian Codegraph @

upstream/mageia-cauldron/man3pm/Test2::Util::Facets2Legacy.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "Test2::Util::Facets2Legacy 3pm"
61 .TH Test2::Util::Facets2Legacy 3pm 2025-06-24 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 Test2::Util::Facets2Legacy \- Convert facet data to the legacy event API.
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This module exports several subroutines from the older event API (see
71 Test2::Event). These subroutines can be used as methods on any object that
72 provides a custom \f(CWfacet_data()\fR method. These subroutines can also be used as
73 functions that take a facet data hashref as arguments.
74 .SH SYNOPSIS
75 .IX Header "SYNOPSIS"
76 .SS "AS METHODS"
77 .IX Subsection "AS METHODS"
78 .Vb 1
79 \& package My::Event;
80 \&
81 \& use Test2::Util::Facets2Legacy \*(Aq:ALL\*(Aq;
82 \&
83 \& sub facet_data { return { ... } }
84 .Ve
85 .PP
86 Then to use it:
87 .PP
88 .Vb 1
89 \& my $e = My::Event\->new(...);
90 \&
91 \& my $causes_fail = $e\->causes_fail;
92 \& my $summary = $e\->summary;
93 \& ....
94 .Ve
95 .SS "AS FUNCTIONS"
96 .IX Subsection "AS FUNCTIONS"
97 .Vb 1
98 \& use Test2::Util::Facets2Legacy \*(Aq:ALL\*(Aq;
99 \&
100 \& my $f = {
101 \& assert => { ... },
102 \& info => [{...}, ...],
103 \& control => {...},
104 \& ...
105 \& };
106 \&
107 \& my $causes_fail = causes_fail($f);
108 \& my $summary = summary($f);
109 .Ve
110 .SH "NOTE ON CYCLES"
111 .IX Header "NOTE ON CYCLES"
112 When used as methods, all these subroutines call \f(CW\*(C`$e\->facet_data()\*(C'\fR. The
113 default \f(CWfacet_data()\fR method in Test2::Event relies on the legacy methods
114 this module emulates in order to work. As a result of this it is very easy to
115 create infinite recursion bugs.
116 .PP
117 These methods have cycle detection and will throw an exception early if a cycle
118 is detected. \f(CWuuid()\fR is currently the only subroutine in this library that
119 has a fallback behavior when cycles are detected.
120 .SH EXPORTS
121 .IX Header "EXPORTS"
122 Nothing is exported by default. You must specify which methods to import, or
123 use the \*(Aq:ALL\*(Aq tag.
124 .ie n .IP "$bool = $e\->\fBcauses_fail()\fR" 4
125 .el .IP "\f(CW$bool\fR = \f(CW$e\fR\->\fBcauses_fail()\fR" 4
126 .IX Item "$bool = $e->causes_fail()"
127 .PD 0
128 .ie n .IP "$bool = causes_fail($f)" 4
129 .el .IP "\f(CW$bool\fR = causes_fail($f)" 4
130 .IX Item "$bool = causes_fail($f)"
131 .PD
132 Check if the event or facets result in a failing state.
133 .ie n .IP "$bool = $e\->\fBdiagnostics()\fR" 4
134 .el .IP "\f(CW$bool\fR = \f(CW$e\fR\->\fBdiagnostics()\fR" 4
135 .IX Item "$bool = $e->diagnostics()"
136 .PD 0
137 .ie n .IP "$bool = diagnostics($f)" 4
138 .el .IP "\f(CW$bool\fR = diagnostics($f)" 4
139 .IX Item "$bool = diagnostics($f)"
140 .PD
141 Check if the event or facets contain any diagnostics information.
142 .ie n .IP "$bool = $e\->\fBglobal()\fR" 4
143 .el .IP "\f(CW$bool\fR = \f(CW$e\fR\->\fBglobal()\fR" 4
144 .IX Item "$bool = $e->global()"
145 .PD 0
146 .ie n .IP "$bool = global($f)" 4
147 .el .IP "\f(CW$bool\fR = global($f)" 4
148 .IX Item "$bool = global($f)"
149 .PD
150 Check if the event or facets need to be globally processed.
151 .ie n .IP "$bool = $e\->\fBincrements_count()\fR" 4
152 .el .IP "\f(CW$bool\fR = \f(CW$e\fR\->\fBincrements_count()\fR" 4
153 .IX Item "$bool = $e->increments_count()"
154 .PD 0
155 .ie n .IP "$bool = increments_count($f)" 4
156 .el .IP "\f(CW$bool\fR = increments_count($f)" 4
157 .IX Item "$bool = increments_count($f)"
158 .PD
159 Check if the event or facets make an assertion.
160 .ie n .IP "$bool = $e\->\fBno_display()\fR" 4
161 .el .IP "\f(CW$bool\fR = \f(CW$e\fR\->\fBno_display()\fR" 4
162 .IX Item "$bool = $e->no_display()"
163 .PD 0
164 .ie n .IP "$bool = no_display($f)" 4
165 .el .IP "\f(CW$bool\fR = no_display($f)" 4
166 .IX Item "$bool = no_display($f)"
167 .PD
168 Check if the event or facets should be rendered or hidden.
169 .ie n .IP "($max, $directive, $reason) = $e\->\fBsets_plan()\fR" 4
170 .el .IP "($max, \f(CW$directive\fR, \f(CW$reason\fR) = \f(CW$e\fR\->\fBsets_plan()\fR" 4
171 .IX Item "($max, $directive, $reason) = $e->sets_plan()"
172 .PD 0
173 .ie n .IP "($max, $directive, $reason) = sets_plan($f)" 4
174 .el .IP "($max, \f(CW$directive\fR, \f(CW$reason\fR) = sets_plan($f)" 4
175 .IX Item "($max, $directive, $reason) = sets_plan($f)"
176 .PD
177 Check if the event or facets set a plan, and return the plan details.
178 .ie n .IP "$id = $e\->\fBsubtest_id()\fR" 4
179 .el .IP "\f(CW$id\fR = \f(CW$e\fR\->\fBsubtest_id()\fR" 4
180 .IX Item "$id = $e->subtest_id()"
181 .PD 0
182 .ie n .IP "$id = subtest_id($f)" 4
183 .el .IP "\f(CW$id\fR = subtest_id($f)" 4
184 .IX Item "$id = subtest_id($f)"
185 .PD
186 Get the subtest id, if any.
187 .ie n .IP "$string = $e\->\fBsummary()\fR" 4
188 .el .IP "\f(CW$string\fR = \f(CW$e\fR\->\fBsummary()\fR" 4
189 .IX Item "$string = $e->summary()"
190 .PD 0
191 .ie n .IP "$string = summary($f)" 4
192 .el .IP "\f(CW$string\fR = summary($f)" 4
193 .IX Item "$string = summary($f)"
194 .PD
195 Get the summary of the event or facets hash, if any.
196 .ie n .IP "$undef_or_int = $e\->\fBterminate()\fR" 4
197 .el .IP "\f(CW$undef_or_int\fR = \f(CW$e\fR\->\fBterminate()\fR" 4
198 .IX Item "$undef_or_int = $e->terminate()"
199 .PD 0
200 .ie n .IP "$undef_or_int = terminate($f)" 4
201 .el .IP "\f(CW$undef_or_int\fR = terminate($f)" 4
202 .IX Item "$undef_or_int = terminate($f)"
203 .PD
204 Check if the event or facets should result in process termination, if so the
205 exit code is returned (which could be 0). undef is returned if no termination
206 is requested.
207 .ie n .IP "$uuid = $e\->\fBuuid()\fR" 4
208 .el .IP "\f(CW$uuid\fR = \f(CW$e\fR\->\fBuuid()\fR" 4
209 .IX Item "$uuid = $e->uuid()"
210 .PD 0
211 .ie n .IP "$uuid = uuid($f)" 4
212 .el .IP "\f(CW$uuid\fR = uuid($f)" 4
213 .IX Item "$uuid = uuid($f)"
214 .PD
215 Get the UUID of the facets or event.
216 .Sp
217 \&\fBNote:\fR This will fall back to \f(CW\*(C`$e\->SUPER::uuid()\*(C'\fR if a cycle is
218 detected and an event is used as the argument.
219 .SH SOURCE
220 .IX Header "SOURCE"
221 The source code repository for Test2 can be found at
222 <https://github.com/Test\-More/test\-more/>.
223 .SH MAINTAINERS
224 .IX Header "MAINTAINERS"
225 .IP "Chad Granum <[email protected]>" 4
226 .IX Item "Chad Granum <[email protected]>"
227 .SH AUTHORS
228 .IX Header "AUTHORS"
229 .IP "Chad Granum <[email protected]>" 4
230 .IX Item "Chad Granum <[email protected]>"
231 .SH COPYRIGHT
232 .IX Header "COPYRIGHT"
233 Copyright Chad Granum <[email protected]>.
234 .PP
235 This program is free software; you can redistribute it and/or
236 modify it under the same terms as Perl itself.
237 .PP
238 See <https://dev.perl.org/licenses/>