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

AUTHOR

250       Ingy dA~Xt Net <ingy@cpan.org>
251
253       Copyright (c) 2006. Ingy dA~Xt Net. All rights reserved.  Copyright (c)
254       2005. Brian Ingerson. All rights reserved.
255
256       This program is free software; you can redistribute it and/or modify it
257       under the same terms as Perl itself.
258
259       See http://www.perl.com/perl/misc/Artistic.html
260
261
262
263perl v5.10.1                      2009-03-06             Test::Base::Filter(3)
Impressum