File: Filter.pod

package info (click to toggle)
libtest-base-perl 0.79-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 664 kB
  • ctags: 108
  • sloc: perl: 952; makefile: 2
file content (309 lines) | stat: -rw-r--r-- 5,448 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
=pod

=for comment
DO NOT EDIT. This Pod was generated by Swim.
See http://github.com/ingydotnet/swim-pm#readme

=encoding utf8

=head1 NAME

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

=head1 SYNOPSIS

      package MyTestSuite;
      use Test::Base -Base;

      ... reusable testing code ...

      package MyTestSuite::Filter;
      use Test::Base::Filter -Base;

      sub my_filter1 {
          ...
      }

=head1 DESCRIPTION

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

=head1 FILTERS

This is a list of the default stock filters (in alphabetic order):

=over

=item C<append>

list => list

Append a string to each element of a list.

    --- numbers lines chomp append=-#\n join
    one
    two
    three

=item C<array>

list => scalar

Turn a list of values into an anonymous array reference.

=item C<base64_decode>

scalar => scalar

Decode base64 data. Useful for binary tests.

=item C<base64_encode>

scalar => scalar

Encode base64 data. Useful for binary tests.

=item C<chomp>

list => list

Remove the final newline from each string value in a list.

=item C<chop>


=back

list => list

    Remove the final char from each string value in a list.

=over

=item C<dumper>

scalar => list

Take a data structure (presumably from another filter like eval) and use
Data::Dumper to dump it in a canonical fashion.

=item C<escape>

scalar => scalar

Unescape all backslash escaped chars.

=item C<eval>

scalar => list

Run Perl's C<eval> command against the data and use the returned value
as the data.

=item C<eval_all>

scalar => list

Run Perl's C<eval> command against the data and return a list of 4 values:

    1) The return value
    2) The error in $@
    3) Captured STDOUT
    4) Captured STDERR

=item C<eval_stderr>

scalar => scalar

Run Perl's C<eval> command against the data and return the captured STDERR.

=item C<eval_stdout>

scalar => scalar

Run Perl's C<eval> command against the data and return the captured STDOUT.

=item C<exec_perl_stdout>

list => scalar

Input Perl code is written to a temp file and run. STDOUT is captured
and returned.

=item C<flatten>

scalar => list

Takes a hash or array ref and flattens it to a list.

=item C<get_url>

scalar => scalar

The text is chomped and considered to be a url. Then LWP::Simple::get is used
to fetch the contents of the url.

=item C<hash>

list => scalar

Turn a list of key/value pairs into an anonymous hash reference.

=item C<head[=number]>

list => list

Takes a list and returns a number of the elements from the front of it. The
default number is one.

=item C<join>

list => scalar

Join a list of strings into a scalar.

=item C<Join>

Join the list of strings inside a list of array refs and return the strings in
place of the array refs.

=item C<lines>

scalar => list

Break the data into an anonymous array of lines. Each line (except
possibly the last one if the C<chomp> filter came first) will have a
newline at the end.

=item C<norm>

scalar => scalar

Normalize the data. Change non-Unix line endings to Unix line endings.

=item C<prepend=string>

list => list

Prepend a string onto each of a list of strings.

=item C<read_file>

scalar => scalar

Read the file named by the current content and return the file's content.

=item C<regexp[=xism]>

scalar => scalar

The C<regexp> filter will turn your data section into a regular expression
object. You can pass in extra flags after an equals sign.

If the text contains more than one line and no flags are specified, then the
'xism' flags are assumed.

=item C<reverse>

list => list

Reverse the elements of a list.

=item C<Reverse>

list => list

Reverse the list of strings inside a list of array refs.

=item C<slice=x[,y]>

list => list

Returns the element number x through element number y of a list.

=item C<sort>

list => list

Sorts the elements of a list in character sort order.

=item C<Sort>

list => list

Sort the list of strings inside a list of array refs.

=item C<split[=string|pattern]>

scalar => list

Split a string in into a list. Takes a optional string or regexp as a
parameter. Defaults to I<s+>. Same as Perl C<split>.

=item C<Split[=string|pattern]>

list => list

Split each of a list of strings and turn them into array refs.

=item C<strict>

scalar => scalar

Prepend the string:

    use strict;
    use warnings;

to the block's text.

=item C<tail[=number]>

list => list

Return a number of elements from the end of a list. The default number is one.

=item C<trim>

list => list

Remove extra blank lines from the beginning and end of the data. This allows
you to visually separate your test data with blank lines.

=item C<unchomp>

list => list

Add a newline to each string value in a list.

=item C<write_file[=filename]>

scalar => scalar

Write the content of the section to the named file. Return the filename.

=item C<yaml>

scalar => list

Apply the YAML::Load function to the data block and use the resultant
structure. Requires YAML.pm.

=back

=head1 AUTHOR

Ingy döt Net <ingy@cpan.org>

=head1 COPYRIGHT

Copyright 2005-2014. Ingy döt Net. All rights reserved.

This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

See L<http://www.perl.com/perl/misc/Artistic.html>

=cut