.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::Base::Filter 3pm" .TH Test::Base::Filter 3pm 2024-03-08 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Test::Base::Filter \- Default Filter Class for Test::Base .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& package MyTestSuite; \& use Test::Base \-Base; \& \& ... reusable testing code ... \& \& package MyTestSuite::Filter; \& use Test::Base::Filter \-Base; \& \& sub my_filter1 { \& ... \& } .Ve .SH DESCRIPTION .IX Header "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. .SH FILTERS .IX Header "FILTERS" This is a list of the default stock filters (in alphabetic order): .ie n .IP """append""" 4 .el .IP \f(CWappend\fR 4 .IX Item "append" list => list .Sp Append a string to each element of a list. .Sp .Vb 4 \& \-\-\- numbers lines chomp append=\-#\en join \& one \& two \& three .Ve .ie n .IP """array""" 4 .el .IP \f(CWarray\fR 4 .IX Item "array" list => scalar .Sp Turn a list of values into an anonymous array reference. .ie n .IP """base64_decode""" 4 .el .IP \f(CWbase64_decode\fR 4 .IX Item "base64_decode" scalar => scalar .Sp Decode base64 data. Useful for binary tests. .ie n .IP """base64_encode""" 4 .el .IP \f(CWbase64_encode\fR 4 .IX Item "base64_encode" scalar => scalar .Sp Encode base64 data. Useful for binary tests. .ie n .IP """chomp""" 4 .el .IP \f(CWchomp\fR 4 .IX Item "chomp" list => list .Sp Remove the final newline from each string value in a list. .ie n .IP """chop""" 4 .el .IP \f(CWchop\fR 4 .IX Item "chop" .PP list => list .PP .Vb 1 \& Remove the final char from each string value in a list. .Ve .ie n .IP """dumper""" 4 .el .IP \f(CWdumper\fR 4 .IX Item "dumper" scalar => list .Sp Take a data structure (presumably from another filter like eval) and use Data::Dumper to dump it in a canonical fashion. .ie n .IP """escape""" 4 .el .IP \f(CWescape\fR 4 .IX Item "escape" scalar => scalar .Sp Unescape all backslash escaped chars. .ie n .IP """eval""" 4 .el .IP \f(CWeval\fR 4 .IX Item "eval" scalar => list .Sp Run Perl's \f(CW\*(C`eval\*(C'\fR command against the data and use the returned value as the data. .ie n .IP """eval_all""" 4 .el .IP \f(CWeval_all\fR 4 .IX Item "eval_all" scalar => list .Sp Run Perl's \f(CW\*(C`eval\*(C'\fR command against the data and return a list of 4 values: .Sp .Vb 4 \& 1) The return value \& 2) The error in $@ \& 3) Captured STDOUT \& 4) Captured STDERR .Ve .ie n .IP """eval_stderr""" 4 .el .IP \f(CWeval_stderr\fR 4 .IX Item "eval_stderr" scalar => scalar .Sp Run Perl's \f(CW\*(C`eval\*(C'\fR command against the data and return the captured STDERR. .ie n .IP """eval_stdout""" 4 .el .IP \f(CWeval_stdout\fR 4 .IX Item "eval_stdout" scalar => scalar .Sp Run Perl's \f(CW\*(C`eval\*(C'\fR command against the data and return the captured STDOUT. .ie n .IP """exec_perl_stdout""" 4 .el .IP \f(CWexec_perl_stdout\fR 4 .IX Item "exec_perl_stdout" list => scalar .Sp Input Perl code is written to a temp file and run. STDOUT is captured and returned. .ie n .IP """flatten""" 4 .el .IP \f(CWflatten\fR 4 .IX Item "flatten" scalar => list .Sp Takes a hash or array ref and flattens it to a list. .ie n .IP """get_url""" 4 .el .IP \f(CWget_url\fR 4 .IX Item "get_url" scalar => scalar .Sp The text is chomped and considered to be a url. Then LWP::Simple::get is used to fetch the contents of the url. .ie n .IP """hash""" 4 .el .IP \f(CWhash\fR 4 .IX Item "hash" list => scalar .Sp Turn a list of key/value pairs into an anonymous hash reference. .ie n .IP """head[=number]""" 4 .el .IP \f(CWhead[=number]\fR 4 .IX Item "head[=number]" list => list .Sp Takes a list and returns a number of the elements from the front of it. The default number is one. .ie n .IP """join""" 4 .el .IP \f(CWjoin\fR 4 .IX Item "join" list => scalar .Sp Join a list of strings into a scalar. .ie n .IP """Join""" 4 .el .IP \f(CWJoin\fR 4 .IX Item "Join" Join the list of strings inside a list of array refs and return the strings in place of the array refs. .ie n .IP """lines""" 4 .el .IP \f(CWlines\fR 4 .IX Item "lines" scalar => list .Sp Break the data into an anonymous array of lines. Each line (except possibly the last one if the \f(CW\*(C`chomp\*(C'\fR filter came first) will have a newline at the end. .ie n .IP """norm""" 4 .el .IP \f(CWnorm\fR 4 .IX Item "norm" scalar => scalar .Sp Normalize the data. Change non-Unix line endings to Unix line endings. .ie n .IP """prepend=string""" 4 .el .IP \f(CWprepend=string\fR 4 .IX Item "prepend=string" list => list .Sp Prepend a string onto each of a list of strings. .ie n .IP """read_file""" 4 .el .IP \f(CWread_file\fR 4 .IX Item "read_file" scalar => scalar .Sp Read the file named by the current content and return the file's content. .ie n .IP """regexp[=xism]""" 4 .el .IP \f(CWregexp[=xism]\fR 4 .IX Item "regexp[=xism]" scalar => scalar .Sp The \f(CW\*(C`regexp\*(C'\fR filter will turn your data section into a regular expression object. You can pass in extra flags after an equals sign. .Sp If the text contains more than one line and no flags are specified, then the \&'xism' flags are assumed. .ie n .IP """reverse""" 4 .el .IP \f(CWreverse\fR 4 .IX Item "reverse" list => list .Sp Reverse the elements of a list. .ie n .IP """Reverse""" 4 .el .IP \f(CWReverse\fR 4 .IX Item "Reverse" list => list .Sp Reverse the list of strings inside a list of array refs. .ie n .IP """slice=x[,y]""" 4 .el .IP \f(CWslice=x[,y]\fR 4 .IX Item "slice=x[,y]" list => list .Sp Returns the element number x through element number y of a list. .ie n .IP """sort""" 4 .el .IP \f(CWsort\fR 4 .IX Item "sort" list => list .Sp Sorts the elements of a list in character sort order. .ie n .IP """Sort""" 4 .el .IP \f(CWSort\fR 4 .IX Item "Sort" list => list .Sp Sort the list of strings inside a list of array refs. .ie n .IP """split[=string|pattern]""" 4 .el .IP \f(CWsplit[=string|pattern]\fR 4 .IX Item "split[=string|pattern]" scalar => list .Sp Split a string in into a list. Takes a optional string or regexp as a parameter. Defaults to \fIs+\fR. Same as Perl \f(CW\*(C`split\*(C'\fR. .ie n .IP """Split[=string|pattern]""" 4 .el .IP \f(CWSplit[=string|pattern]\fR 4 .IX Item "Split[=string|pattern]" list => list .Sp Split each of a list of strings and turn them into array refs. .ie n .IP """strict""" 4 .el .IP \f(CWstrict\fR 4 .IX Item "strict" scalar => scalar .Sp Prepend the string: .Sp .Vb 2 \& use strict; \& use warnings; .Ve .Sp to the block's text. .ie n .IP """tail[=number]""" 4 .el .IP \f(CWtail[=number]\fR 4 .IX Item "tail[=number]" list => list .Sp Return a number of elements from the end of a list. The default number is one. .ie n .IP """trim""" 4 .el .IP \f(CWtrim\fR 4 .IX Item "trim" list => list .Sp Remove extra blank lines from the beginning and end of the data. This allows you to visually separate your test data with blank lines. .ie n .IP """unchomp""" 4 .el .IP \f(CWunchomp\fR 4 .IX Item "unchomp" list => list .Sp Add a newline to each string value in a list. .ie n .IP """write_file[=filename]""" 4 .el .IP \f(CWwrite_file[=filename]\fR 4 .IX Item "write_file[=filename]" scalar => scalar .Sp Write the content of the section to the named file. Return the filename. .ie n .IP """yaml""" 4 .el .IP \f(CWyaml\fR 4 .IX Item "yaml" scalar => list .Sp Apply the YAML::Load function to the data block and use the resultant structure. Requires YAML.pm. .SH AUTHOR .IX Header "AUTHOR" Ingy döt Net .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright 2005\-2018. Ingy döt Net. All rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP See