=encoding utf8 =head1 名前 Test::Base::Filter - Test::Base のデフォルトのフィルタクラス =head1 概要 package MyTestSuite; use Test::Base -Base; ... reusable testing code ... package MyTestSuite::Filter; use Test::Base::Filter -Base; sub my_filter1 { ... } =head1 説明 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. フィルタは Test::Base で効果的なデータ駆動テストを記述する 要の要素です. Test::Base::Filter には汎用的なフィルタの 数多くのデフォルトの集合が含まれています. 機能を追加, 上書きするために サブクラス化することも簡単にできます. =head1 フィルタ This is a list of the default stock filters (in alphabetic order): デフォルトで入っているフィルタは以下の通りです(アルファベット順): =head2 append list => list Append a string to each element of a list. リストの各要素に文字列を追加します. --- numbers lines chomp append=-#\n join one two three =head2 array list => scalar Turn a list of values into an anonymous array reference. 値のリストを無名配列のリファレンスに変換します. =head2 base64_decode scalar => scalar Decode base64 data. Useful for binary tests. base64 データをデコードします. バイナリのテストに便利です. =head2 base64_encode scalar => scalar Encode base64 data. Useful for binary tests. データを base64 エンコードします. バイナリのテストに便利です. =head2 chomp list => list Remove the final newline from each string value in a list. リストの各文字列値から最後の改行文字を取り除きます. =head2 chop list => list Remove the final char from each string value in a list. リストの各文字列値から最後の文字を取り除きます. =head2 dumper scalar => list Take a data structure (presumably from another filter like eval) and use Data::Dumper to dump it in a canonical fashion. データ構造(おそらくeval等他のフィルタで生成されたもの)を受け取って Data::Dumper を使って正規形式にダンプします. =head2 escape scalar => scalar Unescape all backslash escaped chars. バックスラッシュエスケープされた全ての文字をアンエスケープします. =head2 eval scalar => list Run Perl's C command against the data and use the returned value as the data. データに対して Perl の C コマンドを実行し, その復帰値を データとして利用します. =head2 eval_all scalar => list Run Perl's C command against the data and return a list of 4 values: データに対して Perl の C コマンドを実行し, 4つの値から成る リストを返します: 1) The return value 2) The error in $@ 3) Captured STDOUT 4) Captured STDERR 1) 復帰値 2) $@ のエラー内容 3) STDOUT の内容 4) STDERR の内容 =head2 eval_stderr scalar => scalar Run Perl's C command against the data and return the captured STDERR. データに対して Perl の C コマンドを実行し, STDERR から 得られた内容を返します. =head2 eval_stdout scalar => scalar Run Perl's C command against the data and return the captured STDOUT. データに対して Perl の C コマンドを実行し, STDOUT から 得られた内容を返します. =head2 exec_perl_stdout list => scalar Input Perl code is written to a temp file and run. STDOUT is captured and returned. 入力された Perl コードをテンポラリファイルに書き出して実行します. STDOUT を読み込んで返します. =head2 flatten scalar => list Takes a hash or array ref and flattens it to a list. =head2 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. テキストは chomp され, url として扱われます. そしてその url の内容を LWP::Simple::get を使って取得します. =head2 hash list => scalar Turn a list of key/value pairs into an anonymous hash reference. キー/値ペアを無名ハッシュのリファレンスに変換します. =head2 head[=number] list => list Takes a list and returns a number of the elements from the front of it. The default number is one. リストを受け取ってその初めの何個かの要素を返します. 省略時は1つです. =head2 join list => scalar Join a list of strings into a scalar. 文字列のリストをスカラーに join します. =head2 Join Join the list of strings inside a list of array refs and return the strings in place of the array refs. 配列のリストの中にある文字列のリストを join して, 配列リファレンスの 代わりに文字列を返します. =head2 lines scalar => list Break the data into an anonymous array of lines. Each line (except possibly the last one if the C filter came first) will have a newline at the end. データを行の無名配列に砕きます. 各行は終端に改行文字を持ちます (C フィルタが先に適用されていた場合には, 最後の行にはないかもしれません). =head2 norm scalar => scalar Normalize the data. Change non-Unix line endings to Unix line endings. データを正規化(normalize)します. non-Unix 行末を, Unix 行末に変換します. =head2 prepend=string list => list Prepend a string onto each of a list of strings. 文字列のリストの各要素に文字列を前置します. =head2 read_file scalar => scalar Read the file named by the current content and return the file's content. 現在の内容で与えられる名前のファイルを読み込んで, ファイルの内容を返します. =head2 regexp[=xism] scalar => scalar The C filter will turn your data section into a regular expression object. You can pass in extra flags after an equals sign. C フィルタはデータセクションを正規表現オブジェクトに 変換します. 等号記号の後でフラグを指定できます. If the text contains more than one line and no flags are specified, then the 'xism' flags are assumed. テキストが2行以上あってフラグが指定されなかった時には, 'xism' フラグが適用されます. =head2 reverse list => list Reverse the elements of a list. リストの要素を反転します. =head2 Reverse list => list Reverse the list of strings inside a list of array refs. 配列リファレンスのリストの中の文字列のリストを反転します. =head2 slice=x[,y] list => list Returns the element number x through element number y of a list. リストの x 番目から y 番目の要素を返します. =head2 sort list => list Sorts the elements of a list in character sort order. リストの要素を文字列順でソートします. =head2 Sort list => list Sort the list of strings inside a list of array refs. 配列リファレンスのリストの中の文字列のリストをソートします. =head2 split[=string|pattern] scalar => list Split a string in into a list. Takes a optional string or regexp as a parameter. Defaults to /\s+/. Same as Perl C. 文字列をリストに分割(split)します. 任意で文字列若しくは 正規表現をパラメータとして受け取ります. デフォルトは /\s+/ です. Perl の C と同様です. =head2 Split[=string|pattern] list => list Split each of a list of strings and turn them into array refs. 文字列のリストの各要素を split して, 配列のリファレンスにします. =head2 strict scalar => scalar Prepend the string: ブロックのテキストに use strict; use warnings; to the block's text. を前置します. =head2 tail[=number] list => list Return a number of elements from the end of a list. The default number is one. リストの末尾から指定数の要素を返します. 省略時は1つです. =head2 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. データの開始及び終了両側から余計な空行を取り除きます. これを利用することでテストデータに空行を使った視覚的な セパレータを扱うことができます. =head2 unchomp list => list Add a newline to each string value in a list. リストの各文字列値に改行文字を追加します. =head2 write_file[=filename] scalar => scalar Write the content of the section to the named file. Return the filename. セクションの内容を名前付きファイルに書き出します. ファイル名を返します. =head2 yaml scalar => list Apply the YAML::Load function to the data block and use the resultant structure. Requires YAML.pm. データブロックに YAML::Load 関数を適用し, 得られた構造を 利用します. YAML.pm を require します. =head1 著者 Ingy dEt Net =head1 著作権 Copyright (c) 2006. Ingy dEt 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. このプログラムはフリーソフトウェアです。あなたは Perl と同じ ライセンスの 元で再配布及び変更を行うことが出来ます. See http://www.perl.com/perl/misc/Artistic.html 参考 http://www.perl.com/perl/misc/Artistic.html