1Test::Base::Filter(3) User Contributed Perl DocumentationTest::Base::Filter(3)
2
3
4

NAME

6       Test::Base::Filter - Default Filter Class for Test::Base
7

SYNOPSIS

9             package MyTestSuite;
10             use Test::Base -Base;
11
12             ... reusable testing code ...
13
14             package MyTestSuite::Filter;
15             use Test::Base::Filter -Base;
16
17             sub my_filter1 {
18                 ...
19             }
20

DESCRIPTION

22       Filters are the key to writing effective data driven tests with
23       Test::Base.  Test::Base::Filter is a class containing a large default
24       set of generic filters. You can easily subclass it to add/override
25       functionality.
26

FILTERS

28       This is a list of the default stock filters (in alphabetic order):
29
30       "append"
31           list => list
32
33           Append a string to each element of a list.
34
35               --- numbers lines chomp append=-#\n join
36               one
37               two
38               three
39
40       "array"
41           list => scalar
42
43           Turn a list of values into an anonymous array reference.
44
45       "base64_decode"
46           scalar => scalar
47
48           Decode base64 data. Useful for binary tests.
49
50       "base64_encode"
51           scalar => scalar
52
53           Encode base64 data. Useful for binary tests.
54
55       "chomp"
56           list => list
57
58           Remove the final newline from each string value in a list.
59
60       "chop"
61
62       list => list
63
64           Remove the final char from each string value in a list.
65
66       "dumper"
67           scalar => list
68
69           Take a data structure (presumably from another filter like eval)
70           and use Data::Dumper to dump it in a canonical fashion.
71
72       "escape"
73           scalar => scalar
74
75           Unescape all backslash escaped chars.
76
77       "eval"
78           scalar => list
79
80           Run Perl's "eval" command against the data and use the returned
81           value as the data.
82
83       "eval_all"
84           scalar => list
85
86           Run Perl's "eval" command against the data and return a list of 4
87           values:
88
89               1) The return value
90               2) The error in $@
91               3) Captured STDOUT
92               4) Captured STDERR
93
94       "eval_stderr"
95           scalar => scalar
96
97           Run Perl's "eval" command against the data and return the captured
98           STDERR.
99
100       "eval_stdout"
101           scalar => scalar
102
103           Run Perl's "eval" command against the data and return the captured
104           STDOUT.
105
106       "exec_perl_stdout"
107           list => scalar
108
109           Input Perl code is written to a temp file and run. STDOUT is
110           captured and returned.
111
112       "flatten"
113           scalar => list
114
115           Takes a hash or array ref and flattens it to a list.
116
117       "get_url"
118           scalar => scalar
119
120           The text is chomped and considered to be a url. Then
121           LWP::Simple::get is used to fetch the contents of the url.
122
123       "hash"
124           list => scalar
125
126           Turn a list of key/value pairs into an anonymous hash reference.
127
128       "head[=number]"
129           list => list
130
131           Takes a list and returns a number of the elements from the front of
132           it. The default number is one.
133
134       "join"
135           list => scalar
136
137           Join a list of strings into a scalar.
138
139       "Join"
140           Join the list of strings inside a list of array refs and return the
141           strings in place of the array refs.
142
143       "lines"
144           scalar => list
145
146           Break the data into an anonymous array of lines. Each line (except
147           possibly the last one if the "chomp" filter came first) will have a
148           newline at the end.
149
150       "norm"
151           scalar => scalar
152
153           Normalize the data. Change non-Unix line endings to Unix line
154           endings.
155
156       "prepend=string"
157           list => list
158
159           Prepend a string onto each of a list of strings.
160
161       "read_file"
162           scalar => scalar
163
164           Read the file named by the current content and return the file's
165           content.
166
167       "regexp[=xism]"
168           scalar => scalar
169
170           The "regexp" filter will turn your data section into a regular
171           expression object. You can pass in extra flags after an equals
172           sign.
173
174           If the text contains more than one line and no flags are specified,
175           then the 'xism' flags are assumed.
176
177       "reverse"
178           list => list
179
180           Reverse the elements of a list.
181
182       "Reverse"
183           list => list
184
185           Reverse the list of strings inside a list of array refs.
186
187       "slice=x[,y]"
188           list => list
189
190           Returns the element number x through element number y of a list.
191
192       "sort"
193           list => list
194
195           Sorts the elements of a list in character sort order.
196
197       "Sort"
198           list => list
199
200           Sort the list of strings inside a list of array refs.
201
202       "split[=string|pattern]"
203           scalar => list
204
205           Split a string in into a list. Takes a optional string or regexp as
206           a parameter. Defaults to s+. Same as Perl "split".
207
208       "Split[=string|pattern]"
209           list => list
210
211           Split each of a list of strings and turn them into array refs.
212
213       "strict"
214           scalar => scalar
215
216           Prepend the string:
217
218               use strict;
219               use warnings;
220
221           to the block's text.
222
223       "tail[=number]"
224           list => list
225
226           Return a number of elements from the end of a list. The default
227           number is one.
228
229       "trim"
230           list => list
231
232           Remove extra blank lines from the beginning and end of the data.
233           This allows you to visually separate your test data with blank
234           lines.
235
236       "unchomp"
237           list => list
238
239           Add a newline to each string value in a list.
240
241       "write_file[=filename]"
242           scalar => scalar
243
244           Write the content of the section to the named file. Return the
245           filename.
246
247       "yaml"
248           scalar => list
249
250           Apply the YAML::Load function to the data block and use the
251           resultant structure. Requires YAML.pm.
252

AUTHOR

254       Ingy döt Net <ingy@cpan.org>
255
257       Copyright 2005-2018. Ingy döt Net. All rights reserved.
258
259       This program is free software; you can redistribute it and/or modify it
260       under the same terms as Perl itself.
261
262       See <http://www.perl.com/perl/misc/Artistic.html>
263
264
265
266perl v5.32.0                      2020-07-28             Test::Base::Filter(3)
Impressum