Changeset 21807 for inc

Show
Ignore:
Timestamp:
08/06/08 14:23:53 (4 months ago)
Author:
audreyt
Message:

* Upgrade inc/Test/ to newest version.

Location:
inc/Test
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • inc/Test/Base.pm

    r16843 r21807  
    1 #line 1 
    21# TODO: 
    32# 
     
    649648__DATA__ 
    650649 
    651 #line 1328 
     650=head1 NAME 
     651 
     652Test::Base - A Data Driven Testing Framework 
     653 
     654=head1 SYNOPSIS 
     655 
     656A new test module: 
     657 
     658    # lib/MyProject/Test.pm 
     659    package MyProject::Test; 
     660    use Test::Base -Base; 
     661     
     662    use MyProject; 
     663     
     664    package MyProject::Test::Filter; 
     665    use Test::Base::Filter -base; 
     666 
     667    sub my_filter { 
     668        return MyProject->do_something(shift); 
     669    } 
     670 
     671A sample test:     
     672     
     673    # t/sample.t 
     674    use MyProject::Test; 
     675     
     676    plan tests => 1 * blocks; 
     677     
     678    run_is input => 'expected'; 
     679 
     680    sub local_filter { 
     681        s/my/your/; 
     682    } 
     683     
     684    __END__ 
     685     
     686    === Test one (the name of the test) 
     687    --- input my_filter local_filter 
     688    my 
     689    input 
     690    lines 
     691    --- expected 
     692    expected 
     693    output 
     694     
     695    === Test two 
     696    This is an optional description 
     697    of this particular test. 
     698    --- input my_filter 
     699    other 
     700    input 
     701    lines 
     702    --- expected 
     703    other expected 
     704    output 
     705 
     706=head1 DESCRIPTION 
     707 
     708Testing is usually the ugly part of Perl module authoring. Perl gives 
     709you a standard way to run tests with Test::Harness, and basic testing 
     710primitives with Test::More. After that you are pretty much on your own 
     711to develop a testing framework and philosophy. Test::More encourages 
     712you to make your own framework by subclassing Test::Builder, but that is 
     713not trivial. 
     714 
     715Test::Base gives you a way to write your own test framework base 
     716class that I<is> trivial. In fact it is as simple as two lines: 
     717 
     718    package MyTestFramework; 
     719    use Test::Base -Base; 
     720 
     721A module called C<MyTestFramework.pm> containing those two lines, will 
     722give all the power of Test::More and all the power of Test::Base to 
     723every test file that uses it. As you build up the capabilities of 
     724C<MyTestFramework>, your tests will have all of that power as well. 
     725 
     726C<MyTestFramework> becomes a place for you to put all of your reusable 
     727testing bits. As you write tests, you will see patterns and duplication, 
     728and you can "upstream" them into C<MyTestFramework>. Of course, you 
     729don't have to subclass Test::Base at all. You can use it directly in 
     730many applications, including everywhere you would use Test::More. 
     731 
     732Test::Base concentrates on offering reusable data driven patterns, so 
     733that you can write tests with a minimum of code. At the heart of all 
     734testing you have inputs, processes and expected outputs. Test::Base 
     735provides some clean ways for you to express your input and expected 
     736output data, so you can spend your time focusing on that rather than 
     737your code scaffolding. 
     738 
     739=head1 EXPORTED FUNCTIONS 
     740 
     741Test::Base extends Test::More and exports all of its functions. So you 
     742can basically write your tests the same as Test::More. Test::Base 
     743also exports many functions of its own: 
     744 
     745=head2 is(actual, expected, [test-name]) 
     746 
     747This is the equivalent of Test::More's C<is> function with one 
     748interesting twist. If your actual and expected results differ and the 
     749output is multi-line, this function will show you a unified diff format 
     750of output. Consider the benefit when looking for the one character that 
     751is different in hundreds of lines of output! 
     752 
     753Diff output requires the optional C<Text::Diff> CPAN module. If you 
     754don't have this module, the C<is()> function will simply give you normal 
     755Test::More output. To disable diffing altogether, set the 
     756C<TEST_SHOW_NO_DIFFS> environment variable (or C<$ENV{TEST_SHOW_NO_DIFFS}>) 
     757to a true value. You can also call the C<no_diff> function as a shortcut. 
     758 
     759=head2 blocks( [data-section-name] ) 
     760 
     761The most important function is C<blocks>. In list context it returns a 
     762list of C<Test::Base::Block> objects that are generated from the test 
     763specification in the C<DATA> section of your test file. In scalar 
     764context it returns the number of objects. This is useful to calculate 
     765your Test::More plan. 
     766 
     767Each Test::Base::Block object has methods that correspond to the names 
     768of that object's data sections. There is also a C<name> and a 
     769C<description> method for accessing those parts of the block if they 
     770were specified. 
     771 
     772The C<blocks> function can take an optional single argument, that 
     773indicates to only return the blocks that contain a particular named data 
     774section. Otherwise C<blocks> returns all blocks. 
     775 
     776    my @all_of_my_blocks = blocks; 
     777 
     778    my @just_the_foo_blocks = blocks('foo'); 
     779 
     780=head2 next_block() 
     781 
     782You can use the next_block function to iterate over all the blocks. 
     783 
     784    while (my $block = next_block) { 
     785        ... 
     786    } 
     787 
     788It returns undef after all blocks have been iterated over. It can then 
     789be called again to reiterate. 
     790 
     791=head2 first_block() 
     792 
     793Returns the first block or undef if there are none. It resets the iterator to 
     794the C<next_block> function. 
     795 
     796=head2 run(&subroutine) 
     797 
     798There are many ways to write your tests. You can reference each block 
     799individually or you can loop over all the blocks and perform a common 
     800operation. The C<run> function does the looping for you, so all you need 
     801to do is pass it a code block to execute for each block. 
     802 
     803The C<run> function takes a subroutine as an argument, and calls the sub 
     804one time for each block in the specification. It passes the current 
     805block object to the subroutine. 
     806 
     807    run { 
     808        my $block = shift; 
     809        is(process($block->foo), $block->bar, $block->name); 
     810    }; 
     811 
     812=head2 run_is([data_name1, data_name2]) 
     813 
     814Many times you simply want to see if two data sections are equivalent in 
     815every block, probably after having been run through one or more filters. 
     816With the C<run_is> function, you can just pass the names of any two data 
     817sections that exist in every block, and it will loop over every block 
     818comparing the two sections. 
     819 
     820    run_is 'foo', 'bar'; 
     821 
     822If no data sections are given C<run_is> will try to detect them 
     823automatically. 
     824 
     825NOTE: Test::Base will silently ignore any blocks that don't contain 
     826both sections. 
     827 
     828=head2 run_is_deeply([data_name1, data_name2]) 
     829 
     830Like C<run_is> but uses C<is_deeply> for complex data structure comparison. 
     831 
     832=head2 run_like([data_name, regexp | data_name]); 
     833 
     834The C<run_like> function is similar to C<run_is> except the second 
     835argument is a regular expression. The regexp can either be a C<qr{}> 
     836object or a data section that has been filtered into a regular 
     837expression. 
     838 
     839    run_like 'foo', qr{<html.*}; 
     840    run_like 'foo', 'match'; 
     841 
     842=head2 run_unlike([data_name, regexp | data_name]); 
     843 
     844The C<run_unlike> function is similar to C<run_like>, except the opposite. 
     845 
     846    run_unlike 'foo', qr{<html.*}; 
     847    run_unlike 'foo', 'no_match'; 
     848 
     849=head2 run_compare(data_name1, data_name2) 
     850 
     851The C<run_compare> function is like the C<run_is>, C<run_is_deeply> and 
     852the C<run_like> functions all rolled into one. It loops over each 
     853relevant block and determines what type of comparison to do. 
     854 
     855NOTE: If you do not specify either a plan, or run any tests, the 
     856C<run_compare> function will automatically be run. 
     857 
     858=head2 delimiters($block_delimiter, $data_delimiter) 
     859 
     860Override the default delimiters of C<===> and C<--->. 
     861 
     862=head2 spec_file($file_name) 
     863 
     864By default, Test::Base reads its input from the DATA section. This 
     865function tells it to get the spec from a file instead. 
     866 
     867=head2 spec_string($test_data) 
     868 
     869By default, Test::Base reads its input from the DATA section. This 
     870function tells it to get the spec from a string that has been 
     871prepared somehow. 
     872 
     873=head2 filters( @filters_list or $filters_hashref ) 
     874 
     875Specify a list of additional filters to be applied to all blocks. See 
     876L<FILTERS> below. 
     877 
     878You can also specify a hash ref that maps data section names to an array 
     879ref of filters for that data type. 
     880 
     881    filters { 
     882        xxx => [qw(chomp lines)], 
     883        yyy => ['yaml'], 
     884        zzz => 'eval', 
     885    }; 
     886 
     887If a filters list has only one element, the array ref is optional. 
     888 
     889=head2 filters_delay( [1 | 0] ); 
     890 
     891By default Test::Base::Block objects are have all their filters run 
     892ahead of time. There are testing situations in which it is advantageous 
     893to delay the filtering. Calling this function with no arguments or a 
     894true value, causes the filtering to be delayed. 
     895 
     896    use Test::Base; 
     897    filters_delay; 
     898    plan tests => 1 * blocks; 
     899    for my $block (blocks) { 
     900        ... 
     901        $block->run_filters; 
     902        ok($block->is_filtered); 
     903        ... 
     904    } 
     905 
     906In the code above, the filters are called manually, using the 
     907C<run_filters> method of Test::Base::Block. In functions like 
     908C<run_is>, where the tests are run automatically, filtering is delayed 
     909until right before the test. 
     910 
     911=head2 filter_arguments() 
     912 
     913Return the arguments after the equals sign on a filter. 
     914 
     915    sub my_filter { 
     916        my $args = filter_arguments; 
     917        # is($args, 'whazzup'); 
     918        ... 
     919    } 
     920 
     921    __DATA__ 
     922    === A test 
     923    --- data my_filter=whazzup 
     924 
     925=head2 tie_output() 
     926 
     927You can capture STDOUT and STDERR for operations with this function: 
     928 
     929    my $out = ''; 
     930    tie_output(*STDOUT, $buffer); 
     931    print "Hey!\n"; 
     932    print "Che!\n"; 
     933    untie *STDOUT; 
     934    is($out, "Hey!\nChe!\n"); 
     935 
     936=head2 no_diff() 
     937 
     938Turn off diff support for is() in a test file. 
     939 
     940=head2 default_object() 
     941 
     942Returns the default Test::Base object. This is useful if you feel 
     943the need to do an OO operation in otherwise functional test code. See 
     944L<OO> below. 
     945 
     946=head2 WWW() XXX() YYY() ZZZ() 
     947 
     948These debugging functions are exported from the Spiffy.pm module. See 
     949L<Spiffy> for more info. 
     950 
     951=head2 croak() carp() cluck() confess() 
     952 
     953You can use the functions from the Carp module without needing to import 
     954them. Test::Base does it for you by default. 
     955 
     956=head1 TEST SPECIFICATION 
     957 
     958Test::Base allows you to specify your test data in an external file, 
     959the DATA section of your program or from a scalar variable containing 
     960all the text input. 
     961 
     962A I<test specification> is a series of text lines. Each test (or block) 
     963is separated by a line containing the block delimiter and an optional 
     964test C<name>. Each block is further subdivided into named sections with 
     965a line containing the data delimiter and the data section name. A 
     966C<description> of the test can go on lines after the block delimiter but 
     967before the first data section. 
     968 
     969Here is the basic layout of a specification: 
     970 
     971    === <block name 1> 
     972    <optional block description lines> 
     973    --- <data section name 1> <filter-1> <filter-2> <filter-n> 
     974    <test data lines> 
     975    --- <data section name 2> <filter-1> <filter-2> <filter-n> 
     976    <test data lines> 
     977    --- <data section name n> <filter-1> <filter-2> <filter-n> 
     978    <test data lines> 
     979 
     980    === <block name 2> 
     981    <optional block description lines> 
     982    --- <data section name 1> <filter-1> <filter-2> <filter-n> 
     983    <test data lines> 
     984    --- <data section name 2> <filter-1> <filter-2> <filter-n> 
     985    <test data lines> 
     986    --- <data section name n> <filter-1> <filter-2> <filter-n> 
     987    <test data lines> 
     988 
     989Here is a code example: 
     990 
     991    use Test::Base; 
     992     
     993    delimiters qw(### :::); 
     994 
     995    # test code here 
     996 
     997    __END__ 
     998     
     999    ### Test One 
     1000    We want to see if foo and bar 
     1001    are really the same...  
     1002    ::: foo 
     1003    a foo line 
     1004    another foo line 
     1005 
     1006    ::: bar 
     1007    a bar line 
     1008    another bar line 
     1009 
     1010    ### Test Two 
     1011     
     1012    ::: foo 
     1013    some foo line 
     1014    some other foo line 
     1015     
     1016    ::: bar 
     1017    some bar line 
     1018    some other bar line 
     1019 
     1020    ::: baz 
     1021    some baz line 
     1022    some other baz line 
     1023 
     1024This example specifies two blocks. They both have foo and bar data 
     1025sections. The second block has a baz component. The block delimiter is 
     1026C<###> and the data delimiter is C<:::>. 
     1027 
     1028The default block delimiter is C<===> and the default data delimiter 
     1029is C<--->. 
     1030 
     1031There are some special data section names used for control purposes: 
     1032 
     1033    --- SKIP 
     1034    --- ONLY 
     1035    --- LAST 
     1036 
     1037A block with a SKIP section causes that test to be ignored. This is 
     1038useful to disable a test temporarily. 
     1039 
     1040A block with an ONLY section causes only that block to be used. This is 
     1041useful when you are concentrating on getting a single test to pass. If 
     1042there is more than one block with ONLY, the first one will be chosen. 
     1043 
     1044Because ONLY is very useful for debugging and sometimes you forgot to 
     1045remove the ONLY flag before commiting to the VCS or uploading to CPAN, 
     1046Test::Base by default gives you a diag message saying I<I found ONLY 
     1047... maybe you're debugging?>. If you don't like it, use 
     1048C<no_diag_on_only>. 
     1049 
     1050A block with a LAST section makes that block the last one in the 
     1051specification. All following blocks will be ignored. 
     1052 
     1053=head1 FILTERS 
     1054 
     1055The real power in writing tests with Test::Base comes from its 
     1056filtering capabilities. Test::Base comes with an ever growing set 
     1057of useful generic filters than you can sequence and apply to various 
     1058test blocks. That means you can specify the block serialization in 
     1059the most readable format you can find, and let the filters translate 
     1060it into what you really need for a test. It is easy to write your own 
     1061filters as well. 
     1062 
     1063Test::Base allows you to specify a list of filters to each data 
     1064section of each block. The default filters are C<norm> and C<trim>. 
     1065These filters will be applied (in order) to the data after it has been 
     1066parsed from the specification and before it is set into its 
     1067Test::Base::Block object. 
     1068 
     1069You can add to the default filter list with the C<filters> function. You 
     1070can specify additional filters to a specific block by listing them after 
     1071the section name on a data section delimiter line. 
     1072 
     1073Example: 
     1074 
     1075    use Test::Base; 
     1076 
     1077    filters qw(foo bar); 
     1078    filters { perl => 'strict' }; 
     1079 
     1080    sub upper { uc(shift) } 
     1081 
     1082    __END__ 
     1083 
     1084    === Test one 
     1085    --- foo trim chomp upper 
     1086    ... 
     1087 
     1088    --- bar -norm 
     1089    ... 
     1090 
     1091    --- perl eval dumper 
     1092    my @foo = map { 
     1093        - $_; 
     1094    } 1..10; 
     1095    \ @foo; 
     1096 
     1097Putting a C<-> before a filter on a delimiter line, disables that 
     1098filter. 
     1099 
     1100=head2 Scalar vs List 
     1101 
     1102Each filter can take either a scalar or a list as input, and will return 
     1103either a scalar or a list. Since filters are chained together, it is 
     1104important to learn which filters expect which kind of input and return 
     1105which kind of output. 
     1106 
     1107For example, consider the following filter list: 
     1108 
     1109    norm trim lines chomp array dumper eval 
     1110 
     1111The data always starts out as a single scalar string. C<norm> takes a 
     1112scalar and returns a scalar. C<trim> takes a list and returns a list, 
     1113but a scalar is a valid list. C<lines> takes a scalar and returns a 
     1114list. C<chomp> takes a list and returns a list. C<array> takes a list 
     1115and returns a scalar (an anonymous array reference containing the list 
     1116elements). C<dumper> takes a list and returns a scalar. C<eval> takes a 
     1117scalar and creates a list. 
     1118 
     1119A list of exactly one element works fine as input to a filter requiring 
     1120a scalar, but any other list will cause an exception. A scalar in list 
     1121context is considered a list of one element. 
     1122 
     1123Data accessor methods for blocks will return a list of values when used 
     1124in list context, and the first element of the list in scalar context. 
     1125This is usually "the right thing", but be aware. 
     1126 
     1127=head2 The Stock Filters 
     1128 
     1129Test::Base comes with large set of stock filters. They are in the 
     1130C<Test::Base::Filter> module. See L<Test::Base::Filter> for a listing and 
     1131description of these filters. 
     1132 
     1133=head2 Rolling Your Own Filters 
     1134 
     1135Creating filter extensions is very simple. You can either write a 
     1136I<function> in the C<main> namespace, or a I<method> in the 
     1137C<Test::Base::Filter> namespace or a subclass of it. In either case the 
     1138text and any extra arguments are passed in and you return whatever you 
     1139want the new value to be. 
     1140 
     1141Here is a self explanatory example: 
     1142 
     1143    use Test::Base; 
     1144 
     1145    filters 'foo', 'bar=xyz'; 
     1146 
     1147    sub foo { 
     1148        transform(shift); 
     1149    } 
     1150         
     1151    sub Test::Base::Filter::bar { 
     1152        my $self = shift;       # The Test::Base::Filter object 
     1153        my $data = shift; 
     1154        my $args = $self->current_arguments; 
     1155        my $current_block_object = $self->block; 
     1156        # transform $data in a barish manner 
     1157        return $data; 
     1158    } 
     1159 
     1160If you use the method interface for a filter, you can access the block 
     1161internals by calling the C<block> method on the filter object. 
     1162 
     1163Normally you'll probably just use the functional interface, although all 
     1164the builtin filters are methods. 
     1165 
     1166Note that filters defined in the C<main> namespace can look like: 
     1167 
     1168  sub filter9 { 
     1169      s/foo/bar/; 
     1170  } 
     1171 
     1172since Test::Base automatically munges the input string into $_ 
     1173variable and checks the return value of the function to see if it 
     1174looks like a number. If you must define a filter that returns just a 
     1175single number, do it in a different namespace as a method. These 
     1176filters don't allow the simplistic $_ munging. 
     1177 
     1178=head1 OO 
     1179 
     1180Test::Base has a nice functional interface for simple usage. Under the 
     1181hood everything is object oriented. A default Test::Base object is 
     1182created and all the functions are really just method calls on it. 
     1183 
     1184This means if you need to get fancy, you can use all the object 
     1185oriented stuff too. Just create new Test::Base objects and use the 
     1186functions as methods. 
     1187 
     1188    use Test::Base; 
     1189    my $blocks1 = Test::Base->new; 
     1190    my $blocks2 = Test::Base->new; 
     1191 
     1192    $blocks1->delimiters(qw(!!! @@@))->spec_file('test1.txt'); 
     1193    $blocks2->delimiters(qw(### $$$))->spec_string($test_data); 
     1194 
     1195    plan tests => $blocks1->blocks + $blocks2->blocks; 
     1196 
     1197    # ... etc 
     1198 
     1199=head1 THE C<Test::Base::Block> CLASS 
     1200 
     1201In Test::Base, blocks are exposed as Test::Base::Block objects. This 
     1202section lists the methods that can be called on a Test::Base::Block 
     1203object. Of course, each data section name is also available as a method. 
     1204 
     1205=head2 name() 
     1206 
     1207This is the optional short description of a block, that is specified on the 
     1208block separator line. 
     1209 
     1210=head2 description() 
     1211 
     1212This is an optional long description of the block. It is the text taken from 
     1213between the block separator and the first data section. 
     1214 
     1215=head2 seq_num() 
     1216 
     1217Returns a sequence number for this block. Sequence numbers begin with 1.  
     1218 
     1219=head2 blocks_object() 
     1220 
     1221Returns the Test::Base object that owns this block. 
     1222 
     1223=head2 run_filters() 
     1224 
     1225Run the filters on the data sections of the blocks. You don't need to 
     1226use this method unless you also used the C<filters_delay> function. 
     1227 
     1228=head2 is_filtered() 
     1229 
     1230Returns true if filters have already been run for this block. 
     1231 
     1232=head2 original_values() 
     1233 
     1234Returns a hash of the original, unfiltered values of each data section. 
     1235 
     1236=head1 SUBCLASSING 
     1237 
     1238One of the nicest things about Test::Base is that it is easy to 
     1239subclass. This is very important, because in your personal project, you 
     1240will likely want to extend Test::Base with your own filters and other 
     1241reusable pieces of your test framework. 
     1242 
     1243Here is an example of a subclass: 
     1244 
     1245    package MyTestStuff; 
     1246    use Test::Base -Base; 
     1247 
     1248    our @EXPORT = qw(some_func); 
     1249 
     1250    sub some_func { 
     1251        (my ($self), @_) = find_my_self(@_); 
     1252        ... 
     1253    } 
     1254 
     1255    package MyTestStuff::Block; 
     1256    use base 'Test::Base::Block'; 
     1257 
     1258    sub desc { 
     1259        $self->description(@_); 
     1260    } 
     1261 
     1262    package MyTestStuff::Filter; 
     1263    use base 'Test::Base::Filter'; 
     1264 
     1265    sub upper { 
     1266        $self->assert_scalar(@_); 
     1267        uc(shift); 
     1268    } 
     1269 
     1270Note that you don't have to re-Export all the functions from 
     1271Test::Base. That happens automatically, due to the powers of Spiffy. 
     1272 
     1273The first line in C<some_func> allows it to be called as either a 
     1274function or a method in the test code. 
     1275 
     1276=head1 DISTRIBUTION SUPPORT 
     1277 
     1278You might be thinking that you do not want to use Test::Base in you 
     1279modules, because it adds an installation dependency. Fear not. 
     1280Module::Install takes care of that. 
     1281 
     1282Just write a Makefile.PL that looks something like this: 
     1283 
     1284    use inc::Module::Install; 
     1285 
     1286    name            'Foo'; 
     1287    all_from        'lib/Foo.pm'; 
     1288 
     1289    use_test_base; 
     1290 
     1291    WriteAll; 
     1292 
     1293The line with C<use_test_base> will automatically bundle all the code 
     1294the user needs to run Test::Base based tests. 
     1295 
     1296=head1 OTHER COOL FEATURES 
     1297 
     1298Test::Base automatically adds: 
     1299 
     1300    use strict; 
     1301    use warnings; 
     1302 
     1303to all of your test scripts and Test::Base subclasses. A Spiffy 
     1304feature indeed. 
     1305 
     1306=head1 HISTORY 
     1307 
     1308This module started its life with the horrible and ridicule inducing 
     1309name C<Test::Chunks>. It was renamed to C<Test::Base> with the hope 
     1310that it would be seen for the very useful module that it has become. If 
     1311you are switching from C<Test::Chunks> to C<Test::Base>, simply 
     1312substitute the concept and usage of C<chunks> to C<blocks>. 
     1313 
     1314=head1 AUTHOR 
     1315 
     1316Ingy döt Net <ingy@cpan.org> 
     1317 
     1318=head1 COPYRIGHT 
     1319 
     1320Copyright (c) 2006. Ingy döt Net. All rights reserved. 
     1321Copyright (c) 2005. Brian Ingerson. All rights reserved. 
     1322 
     1323This program is free software; you can redistribute it and/or modify it 
     1324under the same terms as Perl itself. 
     1325 
     1326See http://www.perl.com/perl/misc/Artistic.html 
     1327 
     1328=cut 
  • inc/Test/Base/Filter.pm

    r16843 r21807  
    1 #line 1 
    21#. TODO: 
    32#. 
     
    342341__DATA__ 
    343342 
    344 #line 639 
     343=head1 NAME 
     344 
     345Test::Base::Filter - Default Filter Class for Test::Base 
     346 
     347=head1 SYNOPSIS 
     348 
     349    package MyTestSuite; 
     350    use Test::Base -Base; 
     351 
     352    ... reusable testing code ... 
     353 
     354    package MyTestSuite::Filter; 
     355    use Test::Base::Filter -Base; 
     356 
     357    sub my_filter1 { 
     358        ... 
     359    } 
     360 
     361=head1 DESCRIPTION 
     362 
     363Filters are the key to writing effective data driven tests with Test::Base. 
     364Test::Base::Filter is a class containing a large default set of generic 
     365filters. You can easily subclass it to add/override functionality. 
     366 
     367=head1 FILTERS 
     368 
     369This is a list of the default stock filters (in alphabetic order): 
     370 
     371=head2 append 
     372 
     373list => list 
     374 
     375Append a string to each element of a list. 
     376 
     377    --- numbers lines chomp append=-#\n join 
     378    one 
     379    two 
     380    three 
     381 
     382=head2 array 
     383 
     384list => scalar 
     385 
     386Turn a list of values into an anonymous array reference. 
     387 
     388=head2 base64_decode 
     389 
     390scalar => scalar 
     391 
     392Decode base64 data. Useful for binary tests. 
     393 
     394=head2 base64_encode 
     395 
     396scalar => scalar 
     397 
     398Encode base64 data. Useful for binary tests. 
     399 
     400=head2 chomp 
     401 
     402list => list 
     403 
     404Remove the final newline from each string value in a list. 
     405 
     406=head2 chop 
     407 
     408list => list 
     409 
     410Remove the final char from each string value in a list. 
     411 
     412=head2 dumper 
     413 
     414scalar => list 
     415 
     416Take a data structure (presumably from another filter like eval) and use 
     417Data::Dumper to dump it in a canonical fashion. 
     418 
     419=head2 escape 
     420 
     421scalar => scalar 
     422 
     423Unescape all backslash escaped chars. 
     424 
     425=head2 eval 
     426 
     427scalar => list 
     428 
     429Run Perl's C<eval> command against the data and use the returned value 
     430as the data. 
     431 
     432=head2 eval_all 
     433 
     434scalar => list 
     435 
     436Run Perl's C<eval> command against the data and return a list of 4 
     437values: 
     438 
     439    1) The return value 
     440    2) The error in $@ 
     441    3) Captured STDOUT 
     442    4) Captured STDERR 
     443 
     444=head2 eval_stderr 
     445 
     446scalar => scalar 
     447 
     448Run Perl's C<eval> command against the data and return the 
     449captured STDERR. 
     450 
     451=head2 eval_stdout 
     452 
     453scalar => scalar 
     454 
     455Run Perl's C<eval> command against the data and return the 
     456captured STDOUT. 
     457 
     458=head2 exec_perl_stdout 
     459 
     460list => scalar 
     461 
     462Input Perl code is written to a temp file and run. STDOUT is captured and 
     463returned. 
     464 
     465=head2 flatten 
     466 
     467scalar => list 
     468 
     469Takes a hash or array ref and flattens it to a list. 
     470 
     471=head2 get_url 
     472 
     473scalar => scalar 
     474 
     475The text is chomped and considered to be a url. Then LWP::Simple::get is 
     476used to fetch the contents of the url. 
     477 
     478=head2 hash 
     479