1Test::Stream::Exporter(U3s)er Contributed Perl DocumentatTieosnt::Stream::Exporter(3)
2
3
4
6 Test::Stream::Exporter - Declarative exporter for Test::Stream and
7 friends.
8
10 This distribution is deprecated in favor of Test2, Test2::Suite, and
11 Test2::Workflow.
12
13 See Test::Stream::Manual::ToTest2 for a conversion guide.
14
16 Test::Stream::Exporter is an internal implementation of some key
17 features from Exporter::Declare. This is a much more powerful exporting
18 tool than Exporter. This package is used to easily manage complicated
19 export logic across Test::Stream and friends.
20
22 use Test::Stream::Exporter;
23
24 # Export some named subs from the package
25 default_exports qw/foo bar baz/;
26 exports qw/fluxx buxx suxx/;
27
28 # Export some anonymous subs under specific names.
29 export some_tool => sub { ... };
30 default_export another_tool => sub { ... };
31
32 # Call this when you are done providing exports in order to cleanup your
33 # namespace.
34 no Test::Stream::Exporter;
35
36 ...;
37
39 IMPORTING SUBS WITH ALTERNATE NAMES
40 Note: If you import Test::Stream::Exporter functions under alternative
41 names, "no Test::Stream::Exporter;" will not find and remove them like
42 it normally would.
43
44 The rename syntax is borrowed from Exporter::Declare, which borrowed it
45 from Sub::Exporter.
46
47 use Some::Exporter an_export => {-as => 'new_name'}, other_export => {-as => 'other_name'};
48
49 You can also prefix and/or postfix to the names:
50
51 use Some::Exporter an_export => {-preifx => 'my_', postfix '_tool'};
52
53 # Now use it:
54 my_an_export_tool(...);
55
56 IMPORTING ALL SUBS
57 You can use "-all" to import ALL subs exported by a module.
58
59 use Some::Exporter '-all';
60
61 This can be combined with aliasing:
62
63 use Some::Exporter '-all', foo => { -as => 'my_foo' };
64
65 In this example "foo" will be imported as 'my_foo', all other subs will
66 be imported with their original names. Order is not important here.
67
68 IMPORTING DEFAULTS PLUS
69 You can use "-default" to import all default subs, then list others you
70 want to import as well.
71
72 use Some::Exporter '-default', qw/and_this and_that/;
73
74 If you want to import all the defaults AND rename one or more:
75
76 use Some::Exporter '-default', foo => { -as => 'my_foo' };
77
78 In this example "foo()" will be imported as "my_foo()". All other
79 defaults will also be imported, but with their original names. Order is
80 not important here.
81
83 Sometimes you need to make a custom import method, but you still want
84 to use the exporter tool to manage exports. here is how you do it:
85
86 use Test::Stream::Exporter qw/export exports export_from/;
87 export foo => sub { 'foo' };
88 export qw/bar baz/;
89
90 sub import {
91 my $class = shift;
92 my @exports = @_;
93
94 # Do whatever you need to
95 ...
96
97 # Now go ahead and do the exporting with your list
98 my $caller = caller;
99 export_from($class, $caller, \@exports);
100 }
101
102 # This will cleanup the namespace, including 'export_from', do you need to
103 # do it AFTER your import method.
104 no Test::Stream::Exporter;
105
106 sub bar { 'bar' }
107 sub baz { 'baz' }
108
109 1;
110
112 DEFAULT
113 METHODS
114
115 $class->import(@list)
116 Your class needs this to function as an exporter.
117
118 FUNCTIONS
119
120 Note: All of thease are removed by default when you run "no
121 Test::Stream::Exporter;"
122
123 export NAME => sub { ... }
124 default_export NAME => sub { ... }
125 These are used to define exports that may not actually be subs in
126 the current package.
127
128 exports qw/foo bar baz/
129 default_exports qw/foo bar baz/
130 These let you export package subs en mass.
131
132 OTHER AVAILABLE EXPORTS
133 METHODS
134
135 $class->export_to($dest)
136 $class->export_to($dest, \@symbols)
137 Export from the exporter class into the $dest package. The seconond
138 argument is optional, if it is omitted the default export list will
139 be used. The second argument must be an arrayref with export names.
140
141 FUNCTIONS
142
143 Note: All of thease are removed by default when you run "no
144 Test::Stream::Exporter;"
145
146 export_from($from, $to)
147 export_from($from, $to, \@symbols)
148 This will export all the specified symbols from the $from package
149 to the $to package.
150
152 The source code repository for Test::Stream can be found at
153 http://github.com/Test-More/Test-Stream/.
154
156 Chad Granum <exodist@cpan.org>
157
159 Chad Granum <exodist@cpan.org>
160 Kent Fredric <kentnl@cpan.org>
161
163 Copyright 2015 Chad Granum <exodist7@gmail.com>.
164
165 This program is free software; you can redistribute it and/or modify it
166 under the same terms as Perl itself.
167
168 See http://dev.perl.org/licenses/
169
170
171
172perl v5.32.0 2020-07-28 Test::Stream::Exporter(3)