use strict; use vars qw( @tokens ); BEGIN { @tokens = ( "\n", "\n", "\nVous Etes Perdu ?\n", "\n", "\n", "\n", "Perdu sur l'Internet ?", "\n", "Pas de panique, on va vous aider", "\n", " * ", "<-", "---- vous ", "tes ici", "\n", "\n", "\n\n" ); } use Test::More tests => 2 + scalar @tokens; use HTTP::Proxy::BodyFilter::htmltext; # the tests are in the HTTP::Proxy::BodyFilter::htmltext callback my $sub = sub { is( $_, shift (@tokens), "Correct text token matched" ); }; my $data = qq{\n\n\nVous Etes Perdu ?\n\n\n\n

Perdu sur l'Internet ?

\n

Pas de panique, on va vous aider

\n
    * <----- vous êtes ici
\n\n\n\n}; my $result = $data; # test the filter's parser my $filter = HTTP::Proxy::BodyFilter::htmltext->new($sub); $filter->filter( \$data, undef, undef, undef ); is( $data, $result, "Text data not modified" ); # test the result data when modified $result = $data = "

This is a test.

\n

Yes, a test

\n"; $result =~ s/test/foobar/g; $filter = HTTP::Proxy::BodyFilter::htmltext->new( sub { s/test/foobar/g } ); $filter->filter( \$data, undef, undef, undef ); is( $data, $result, "Text data correctly transformed" );