Rechercher une page de manuel
Test::Base::Filter.3pm
Langue: en
Version: 2009-03-06 (debian - 07/07/09)
Section: 3 (Bibliothèques de fonctions)
Sommaire
- NAME
- SYNOPSIS
- DESCRIPTION
- FILTERS
- append
- array
- base64_decode
- base64_encode
- chomp
- chop
- dumper
- escape
- eval
- eval_all
- eval_stderr
- eval_stdout
- exec_perl_stdout
- flatten
- get_url
- hash
- head[=number]
- join
- Join
- lines
- norm
- prepend=string
- read_file
- regexp[=xism]
- reverse
- Reverse
- slice=x[,y]
- sort
- Sort
- split[=string|pattern]
- Split[=string|pattern]
- strict
- tail[=number]
- trim
- unchomp
- write_file[=filename]
- yaml
- AUTHOR
- COPYRIGHT
NAME
Test::Base::Filter - Default Filter Class for Test::BaseSYNOPSIS
package MyTestSuite; use Test::Base -Base; ... reusable testing code ... package MyTestSuite::Filter; use Test::Base::Filter -Base; sub my_filter1 { ... }
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.FILTERS
This is a list of the default stock filters (in alphabetic order):append
list => listAppend a string to each element of a list.
--- numbers lines chomp append=-#\n join one two three
array
list => scalarTurn a list of values into an anonymous array reference.
base64_decode
scalar => scalarDecode base64 data. Useful for binary tests.
base64_encode
scalar => scalarEncode base64 data. Useful for binary tests.
chomp
list => listRemove the final newline from each string value in a list.
chop
list => listRemove the final char from each string value in a list.
dumper
scalar => listTake a data structure (presumably from another filter like eval) and use Data::Dumper to dump it in a canonical fashion.
escape
scalar => scalarUnescape all backslash escaped chars.
eval
scalar => listRun Perl's "eval" command against the data and use the returned value as the data.
eval_all
scalar => listRun 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
eval_stderr
scalar => scalarRun Perl's "eval" command against the data and return the captured STDERR.
eval_stdout
scalar => scalarRun Perl's "eval" command against the data and return the captured STDOUT.
exec_perl_stdout
list => scalarInput Perl code is written to a temp file and run. STDOUT is captured and returned.
flatten
scalar => listTakes a hash or array ref and flattens it to a list.
get_url
scalar => scalarThe text is chomped and considered to be a url. Then LWP::Simple::get is used to fetch the contents of the url.
hash
list => scalarTurn a list of key/value pairs into an anonymous hash reference.
head[=number]
list => listTakes a list and returns a number of the elements from the front of it. The default number is one.
join
list => scalarJoin a list of strings into a scalar.
Join
Join the list of strings inside a list of array refs and return the strings in place of the array refs.lines
scalar => listBreak 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.
norm
scalar => scalarNormalize the data. Change non-Unix line endings to Unix line endings.
prepend=string
list => listPrepend a string onto each of a list of strings.
read_file
scalar => scalarRead the file named by the current content and return the file's content.
regexp[=xism]
scalar => scalarThe "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
list => listReverse the elements of a list.
Reverse
list => listReverse the list of strings inside a list of array refs.
slice=x[,y]
list => listReturns the element number x through element number y of a list.
sort
list => listSorts the elements of a list in character sort order.
Sort
list => listSort the list of strings inside a list of array refs.
split[=string|pattern]
scalar => listSplit a string in into a list. Takes a optional string or regexp as a parameter. Defaults to /\s+/. Same as Perl "split".
Split[=string|pattern]
list => listSplit each of a list of strings and turn them into array refs.
strict
scalar => scalarPrepend the string:
use strict; use warnings;
to the block's text.
tail[=number]
list => listReturn a number of elements from the end of a list. The default number is one.
trim
list => listRemove extra blank lines from the beginning and end of the data. This allows you to visually separate your test data with blank lines.
unchomp
list => listAdd a newline to each string value in a list.
write_file[=filename]
scalar => scalarWrite the content of the section to the named file. Return the filename.
yaml
scalar => listApply the YAML::Load function to the data block and use the resultant structure. Requires YAML.pm.
AUTHOR
Ingy dA~Xt Net <ingy@cpan.org>COPYRIGHT
Copyright (c) 2006. Ingy dA~Xt Net. All rights reserved. Copyright (c) 2005. Brian Ingerson. 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
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre