Test::HTML::Formatter->test_files(
class_suffix
=>
'FormatPS'
,
filename_extension
=>
'ps'
,
callback_test_file
=>
sub
{
my
(
$self
,
$infile
,
$expfile
) =
@_
;
local
(
*FH
);
open
( FH,
$expfile
) or
die
"Unable to open expected file $expfile - $!\n"
;
my
$exp_text
=
do
{
local
($/); <FH> };
my
$exp_lines
= [
grep
!/^\%\%/, (
split
( /\n/,
$exp_text
) ) ];
my
$text
= HTML::FormatPS->format_file(
$infile
,
leftmargin
=> 5,
rightmargin
=> 50 );
my
$got_lines
= [
grep
!/^\%\%/, (
split
( /\n/,
$text
) ) ];
ok(
length
(
$text
),
' Returned a string from conversion'
);
is(
scalar
( @{
$got_lines
} ),
scalar
( @{
$exp_lines
} ),
"Same number of lines returned"
);
my
$ok_count
= 0;
for
(
my
$line_no
= 0; (
$line_no
<= $
$ok_count
++
if
(
$got_lines
->[
$line_no
] eq
$exp_lines
->[
$line_no
] );
}
if
(
scalar
( @{
$got_lines
} ) ==
$ok_count
) {
pass(
' Perfect match of postcript output'
);
}
else
{
ok( ( (
scalar
( @{
$got_lines
} ) -
$ok_count
) <= (
scalar
( @{
$got_lines
} ) / 10 ) ),
' Better than 90% output lines match'
);
}
},
);
done_testing();