Test::Base::Filter(3) | User Contributed Perl Documentation | Test::Base::Filter(3) |
Test::Base::Filter - Default Filter Class for Test::Base
package MyTestSuite; use Test::Base -Base; ... reusable testing code ... package MyTestSuite::Filter; use Test::Base::Filter -Base; sub my_filter1 { ... }
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.
This is a list of the default stock filters (in alphabetic order):
Append a string to each element of a list.
--- numbers lines chomp append=-#\n join one two three
Turn a list of values into an anonymous array reference.
Decode base64 data. Useful for binary tests.
Encode base64 data. Useful for binary tests.
Remove the final newline from each string value in a list.
list => list
Remove the final char from each string value in a list.
Take a data structure (presumably from another filter like eval) and use Data::Dumper to dump it in a canonical fashion.
Unescape all backslash escaped chars.
Run Perl's "eval" command against the data and use the returned value as the data.
Run Perl's "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
Run Perl's "eval" command against the data and return the captured STDERR.
Run Perl's "eval" command against the data and return the captured STDOUT.
Input Perl code is written to a temp file and run. STDOUT is captured and returned.
Takes a hash or array ref and flattens it to a list.
The text is chomped and considered to be a url. Then LWP::Simple::get is used to fetch the contents of the url.
Turn a list of key/value pairs into an anonymous hash reference.
Takes a list and returns a number of the elements from the front of it. The default number is one.
Join a list of strings into a scalar.
Break the data into an anonymous array of lines. Each line (except possibly the last one if the "chomp" filter came first) will have a newline at the end.
Normalize the data. Change non-Unix line endings to Unix line endings.
Prepend a string onto each of a list of strings.
Read the file named by the current content and return the file's content.
The "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.
Reverse the elements of a list.
Reverse the list of strings inside a list of array refs.
Returns the element number x through element number y of a list.
Sorts the elements of a list in character sort order.
Sort the list of strings inside a list of array refs.
Split a string in into a list. Takes a optional string or regexp as a parameter. Defaults to s+. Same as Perl "split".
Split each of a list of strings and turn them into array refs.
Prepend the string:
use strict; use warnings;
to the block's text.
Return a number of elements from the end of a list. The default number is one.
Remove extra blank lines from the beginning and end of the data. This allows you to visually separate your test data with blank lines.
Add a newline to each string value in a list.
Write the content of the section to the named file. Return the filename.
Apply the YAML::Load function to the data block and use the resultant structure. Requires YAML.pm.
Ingy döt Net <ingy@cpan.org>
Copyright 2005-2018. 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 <http://www.perl.com/perl/misc/Artistic.html>
2018-04-19 | perl v5.34.0 |