Debian Codegraph @

upstream/debian-unstable/man3/TAP::Parser::ResultFactory.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (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 .\"
57 .IX Title "TAP::Parser::ResultFactory 3perl"
58 .TH TAP::Parser::ResultFactory 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 TAP::Parser::ResultFactory \- Factory for creating TAP::Parser output objects
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 4
68 \& use TAP::Parser::ResultFactory;
69 \& my $token = {...};
70 \& my $factory = TAP::Parser::ResultFactory\->new;
71 \& my $result = $factory\->make_result( $token );
72 .Ve
73 .SH VERSION
74 .IX Header "VERSION"
75 Version 3.48
76 .SS DESCRIPTION
77 .IX Subsection "DESCRIPTION"
78 This is a simple factory class which returns a TAP::Parser::Result subclass
79 representing the current bit of test data from TAP (usually a single line).
80 It is used primarily by TAP::Parser::Grammar. Unless you're subclassing,
81 you probably won't need to use this module directly.
82 .SS METHODS
83 .IX Subsection "METHODS"
84 .SS "Class Methods"
85 .IX Subsection "Class Methods"
86 \fR\f(CI\*(C`new\*(C'\fR\fI\fR
87 .IX Subsection "new"
88 .PP
89 Creates a new factory class.
90 \&\fINote:\fR You currently don't need to instantiate a factory in order to use it.
91 .PP
92 \fR\f(CI\*(C`make_result\*(C'\fR\fI\fR
93 .IX Subsection "make_result"
94 .PP
95 Returns an instance the appropriate class for the test token passed in.
96 .PP
97 .Vb 1
98 \& my $result = TAP::Parser::ResultFactory\->make_result($token);
99 .Ve
100 .PP
101 Can also be called as an instance method.
102 .PP
103 \fR\f(CI\*(C`class_for\*(C'\fR\fI\fR
104 .IX Subsection "class_for"
105 .PP
106 Takes one argument: \f(CW$type\fR. Returns the class for this \f(CW$type\fR, or \f(CW\*(C`croak\*(C'\fRs
107 with an error.
108 .PP
109 \fR\f(CI\*(C`register_type\*(C'\fR\fI\fR
110 .IX Subsection "register_type"
111 .PP
112 Takes two arguments: \f(CW$type\fR, \f(CW$class\fR
113 .PP
114 This lets you override an existing type with your own custom type, or register
115 a completely new type, eg:
116 .PP
117 .Vb 4
118 \& # create a custom result type:
119 \& package MyResult;
120 \& use strict;
121 \& use base \*(AqTAP::Parser::Result\*(Aq;
122 \&
123 \& # register with the factory:
124 \& TAP::Parser::ResultFactory\->register_type( \*(Aqmy_type\*(Aq => _\|_PACKAGE_\|_ );
125 \&
126 \& # use it:
127 \& my $r = TAP::Parser::ResultFactory\->( { type => \*(Aqmy_type\*(Aq } );
128 .Ve
129 .PP
130 Your custom type should then be picked up automatically by the TAP::Parser.
131 .SH SUBCLASSING
132 .IX Header "SUBCLASSING"
133 Please see "SUBCLASSING" in TAP::Parser for a subclassing overview.
134 .PP
135 There are a few things to bear in mind when creating your own
136 \&\f(CW\*(C`ResultFactory\*(C'\fR:
137 .IP 1. 4
138 The factory itself is never instantiated (this \fImay\fR change in the future).
139 This means that \f(CW\*(C`_initialize\*(C'\fR is never called.
140 .IP 2. 4
141 \&\f(CW\*(C`TAP::Parser::Result\->new\*(C'\fR is never called, \f(CW$tokens\fR are reblessed.
142 This \fIwill\fR change in a future version!
143 .IP 3. 4
144 TAP::Parser::Result subclasses will register themselves with
145 TAP::Parser::ResultFactory directly:
146 .Sp
147 .Vb 2
148 \& package MyFooResult;
149 \& TAP::Parser::ResultFactory\->register_type( foo => _\|_PACKAGE_\|_ );
150 .Ve
151 .Sp
152 Of course, it's up to you to decide whether or not to ignore them.
153 .SS Example
154 .IX Subsection "Example"
155 .Vb 1
156 \& package MyResultFactory;
157 \&
158 \& use strict;
159 \&
160 \& use MyResult;
161 \&
162 \& use base \*(AqTAP::Parser::ResultFactory\*(Aq;
163 \&
164 \& # force all results to be \*(AqMyResult\*(Aq
165 \& sub class_for {
166 \& return \*(AqMyResult\*(Aq;
167 \& }
168 \&
169 \& 1;
170 .Ve
171 .SH "SEE ALSO"
172 .IX Header "SEE ALSO"
173 TAP::Parser,
174 TAP::Parser::Result,
175 TAP::Parser::Grammar