Debian Codegraph @

upstream/opensuse-tumbleweed/man3/Test2::Util::Sub.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::Sub 3pm"
61 .TH Test2::Util::Sub 3pm 2026-03-09 "perl v5.42.1" "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::Sub \- Tools for inspecting and manipulating subs.
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 Utilities used by Test2::Tools to inspect and manipulate subroutines.
71 .SH EXPORTS
72 .IX Header "EXPORTS"
73 All exports are optional, you must specify subs to import.
74 .ie n .IP "$name = sub_name(\e&sub)" 4
75 .el .IP "\f(CW$name\fR = sub_name(\e&sub)" 4
76 .IX Item "$name = sub_name(&sub)"
77 Get the name of the sub.
78 .ie n .IP "my $hr = sub_info(\e&code)" 4
79 .el .IP "my \f(CW$hr\fR = sub_info(\e&code)" 4
80 .IX Item "my $hr = sub_info(&code)"
81 This returns a hashref with information about the sub:
82 .Sp
83 .Vb 6
84 \& {
85 \& ref => \e&code,
86 \& cobj => $cobj,
87 \& name => "Some::Mod::code",
88 \& file => "Some/Mod.pm",
89 \& package => "Some::Mod",
90 \&
91 \& # Note: These have been adjusted based on guesswork.
92 \& start_line => 22,
93 \& end_line => 42,
94 \& lines => [22, 42],
95 \&
96 \& # Not a bug, these lines are different!
97 \& all_lines => [23, 25, ..., 39, 41],
98 \& };
99 .Ve
100 .RS 4
101 .ie n .IP "$info\->{ref} => \e&code" 4
102 .el .IP "\f(CW$info\fR\->{ref} => \e&code" 4
103 .IX Item "$info->{ref} => &code"
104 This is the original sub passed to \f(CWsub_info()\fR.
105 .ie n .IP "$info\->{cobj} => $cobj" 4
106 .el .IP "\f(CW$info\fR\->{cobj} => \f(CW$cobj\fR" 4
107 .IX Item "$info->{cobj} => $cobj"
108 This is the c\-object representation of the coderef.
109 .ie n .IP "$info\->{name} => ""Some::Mod::code""" 4
110 .el .IP "\f(CW$info\fR\->{name} => ""Some::Mod::code""" 4
111 .IX Item "$info->{name} => ""Some::Mod::code"""
112 This is the name of the coderef. For anonymous coderefs this may end with
113 \&\f(CW\*(Aq_\|_ANON_\|_\*(Aq\fR. Also note that the package \*(Aqmain\*(Aq is special, and \*(Aqmain::\*(Aq may
114 be omitted.
115 .ie n .IP "$info\->{file} => ""Some/Mod.pm""" 4
116 .el .IP "\f(CW$info\fR\->{file} => ""Some/Mod.pm""" 4
117 .IX Item "$info->{file} => ""Some/Mod.pm"""
118 The file in which the sub was defined.
119 .ie n .IP "$info\->{package} => ""Some::Mod""" 4
120 .el .IP "\f(CW$info\fR\->{package} => ""Some::Mod""" 4
121 .IX Item "$info->{package} => ""Some::Mod"""
122 The package in which the sub was defined.
123 .ie n .IP "$info\->{start_line} => 22" 4
124 .el .IP "\f(CW$info\fR\->{start_line} => 22" 4
125 .IX Item "$info->{start_line} => 22"
126 .PD 0
127 .ie n .IP "$info\->{end_line} => 42" 4
128 .el .IP "\f(CW$info\fR\->{end_line} => 42" 4
129 .IX Item "$info->{end_line} => 42"
130 .ie n .IP "$info\->{lines} => [22, 42]" 4
131 .el .IP "\f(CW$info\fR\->{lines} => [22, 42]" 4
132 .IX Item "$info->{lines} => [22, 42]"
133 .PD
134 These three fields are the \fIadjusted\fR start line, end line, and array with both.
135 It is important to note that these lines have been adjusted and may not be
136 accurate.
137 .Sp
138 The lines are obtained by walking the ops. As such, the first line is the line
139 of the first statement, and the last line is the line of the last statement.
140 This means that in multi\-line subs the lines are usually off by 1. The lines
141 in these keys will be adjusted for you if it detects a multi\-line sub.
142 .ie n .IP "$info\->{all_lines} => [23, 25, ..., 39, 41]" 4
143 .el .IP "\f(CW$info\fR\->{all_lines} => [23, 25, ..., 39, 41]" 4
144 .IX Item "$info->{all_lines} => [23, 25, ..., 39, 41]"
145 This is an array with the lines of every statement in the sub. Unlike the other
146 line fields, these have not been adjusted for you.
147 .RE
148 .RS 4
149 .RE
150 .SH SOURCE
151 .IX Header "SOURCE"
152 The source code repository for Test2\-Suite can be found at
153 \&\fIhttps://github.com/Test\-More/test\-more/\fR.
154 .SH MAINTAINERS
155 .IX Header "MAINTAINERS"
156 .IP "Chad Granum <[email protected]>" 4
157 .IX Item "Chad Granum <[email protected]>"
158 .SH AUTHORS
159 .IX Header "AUTHORS"
160 .IP "Chad Granum <[email protected]>" 4
161 .IX Item "Chad Granum <[email protected]>"
162 .PD 0
163 .IP "Kent Fredric <[email protected]>" 4
164 .IX Item "Kent Fredric <[email protected]>"
165 .PD
166 .SH COPYRIGHT
167 .IX Header "COPYRIGHT"
168 Copyright Chad Granum <[email protected]>.
169 .PP
170 This program is free software; you can redistribute it and/or
171 modify it under the same terms as Perl itself.
172 .PP
173 See \fIhttp://dev.perl.org/licenses/\fR