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

AUTHOR

287       Ingy döt Net <ingy@cpan.org>
288
290       Copyright (c) 2006. Ingy döt Net. All rights reserved.  Copyright (c)
291       2005. Brian Ingerson. All rights reserved.
292
293       This program is free software; you can redistribute it and/or modify it
294       under the same terms as Perl itself.
295
296       See http://www.perl.com/perl/misc/Artistic.html
297
298
299
300perl v5.8.8                       2006-08-26             Test::Base::Filter(3)
Impressum