Debian Codegraph @

upstream/opensuse-tumbleweed/man3/Test2::Tools::Exports.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::Tools::Exports 3pm"
61 .TH Test2::Tools::Exports 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::Tools::Exports \- Tools for validating exporters.
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 These are tools for checking that symbols have been imported into your
71 namespace.
72 .SH SYNOPSIS
73 .IX Header "SYNOPSIS"
74 .Vb 1
75 \& use Test2::Tools::Exports
76 \&
77 \& use Data::Dumper;
78 \& imported_ok qw/Dumper/;
79 \& not_imported_ok qw/dumper/;
80 .Ve
81 .SH EXPORTS
82 .IX Header "EXPORTS"
83 All subs are exported by default.
84 .IP imported_ok(@SYMBOLS) 4
85 .IX Item "imported_ok(@SYMBOLS)"
86 Check that the specified symbols exist in the current package. This will not
87 find inherited subs. This will only find symbols in the current package\*(Aqs symbol
88 table. This \fBWILL NOT\fR confirm that the symbols were defined outside of the
89 package itself.
90 .Sp
91 .Vb 1
92 \& imported_ok( \*(Aq$scalar\*(Aq, \*(Aq@array\*(Aq, \*(Aq%hash\*(Aq, \*(Aq&sub\*(Aq, \*(Aqalso_a_sub\*(Aq );
93 .Ve
94 .Sp
95 \&\f(CW@SYMBOLS\fR can contain any number of symbols. Each item in the array must be a
96 string. The string should be the name of a symbol. If a sigil is present then
97 it will search for that specified type, if no sigil is specified it will be
98 used as a sub name.
99 .IP not_imported_ok(@SYMBOLS) 4
100 .IX Item "not_imported_ok(@SYMBOLS)"
101 Check that the specified symbols do not exist in the current package. This will
102 not find inherited subs. This will only look at symbols in the current package\*(Aqs
103 symbol table.
104 .Sp
105 .Vb 1
106 \& not_imported_ok( \*(Aq$scalar\*(Aq, \*(Aq@array\*(Aq, \*(Aq%hash\*(Aq, \*(Aq&sub\*(Aq, \*(Aqalso_a_sub\*(Aq );
107 .Ve
108 .Sp
109 \&\f(CW@SYMBOLS\fR can contain any number of symbols. Each item in the array must be a
110 string. The string should be the name of a symbol. If a sigil is present, then
111 it will search for that specified type. If no sigil is specified, it will be
112 used as a sub name.
113 .SH CAVEATS
114 .IX Header "CAVEATS"
115 Before Perl 5.10, it is very difficult to distinguish between a package scalar
116 that is undeclared vs declared and undefined. Currently \f(CW\*(C`imported_ok\*(C'\fR and
117 \&\f(CW\*(C`not_imported_ok\*(C'\fR cannot see package scalars declared using \f(CW\*(C`our $var\*(C'\fR unless
118 the variable has been assigned a defined value.
119 .PP
120 This will pass on recent perls, but fail on perls older than 5.10:
121 .PP
122 .Vb 1
123 \& use Test2::Tools::Exports;
124 \&
125 \& our $foo;
126 \&
127 \& # Fails on perl onlder than 5.10
128 \& imported_ok(qw/$foo/);
129 .Ve
130 .PP
131 If \f(CW$foo\fR is imported from another module, or imported using
132 \&\f(CW\*(C`use vars qw/$foo/;\*(C'\fR then it will work on all supported perl versions.
133 .PP
134 .Vb 1
135 \& use Test2::Tools::Exports;
136 \&
137 \& use vars qw/$foo/;
138 \& use Some::Module qw/$bar/;
139 \&
140 \& # Always works
141 \& imported_ok(qw/$foo $bar/);
142 .Ve
143 .SH SOURCE
144 .IX Header "SOURCE"
145 The source code repository for Test2\-Suite can be found at
146 \&\fIhttps://github.com/Test\-More/test\-more/\fR.
147 .SH MAINTAINERS
148 .IX Header "MAINTAINERS"
149 .IP "Chad Granum <[email protected]>" 4
150 .IX Item "Chad Granum <[email protected]>"
151 .SH AUTHORS
152 .IX Header "AUTHORS"
153 .IP "Chad Granum <[email protected]>" 4
154 .IX Item "Chad Granum <[email protected]>"
155 .SH COPYRIGHT
156 .IX Header "COPYRIGHT"
157 Copyright Chad Granum <[email protected]>.
158 .PP
159 This program is free software; you can redistribute it and/or
160 modify it under the same terms as Perl itself.
161 .PP
162 See \fIhttp://dev.perl.org/licenses/\fR