# 03_output.t
use strict;
use Cwd;
use Pod::Html;
use Test::More;
if ($] < 5.007) {
plan skip_all => "Test::Output unreliable on 5.6.x, this is $]";
}
elsif (do {eval "use Test::Output" or $@}) {
plan skip_all =>'Test::Output not available';
}
else {
plan tests => 14;
}
my $CWD = Cwd::cwd();
my $CACHEDIR = "$CWD/t/subdir";
stderr_is(
sub {pod2html('--infile=t/fragment.pod', '--outfile=t/fragment.out')},
'', 'no news is good news'
);
stderr_is(
sub {pod2html('--outfile=t/fragment.out', 't/fragment.pod')},
'', 'no news is better news'
);
stderr_is(
sub {pod2html('--infile=t/unclosed.pod', '--outfile=t/unclosed.out')},
< in paragraph 3: 'bold'.
t/03_output.t: t/unclosed.pod: undelimited C<> in paragraph 4 (_go_ahead): 'code'.
EOM
);
stderr_is(
sub {pod2html('--infile=t/unclosed.pod', '--outfile=t/unclosed.out', '--quiet')},
'',
'unclosed silent'
);
stderr_is( sub {pod2html(
'--infile=t/notitle.pod',
'--outfile=t/notitle.out',
'--verbose',
)}, < in paragraph $para[0].
t/03_output.t: t/torture.pod: unknown pod directive 'bogus' in paragraph $para[1]. ignoring.
t/03_output.t: t/torture.pod: unexpected =back directive in paragraph $para[2]. ignoring.
t/03_output.t: t/torture.pod: invalid X<> in paragraph $para[3].
t/03_output.t: t/torture.pod: unknown pod directive 'comment' in paragraph $para[4]. ignoring.
t/03_output.t: t/torture.pod: unexpected =item directive in paragraph $para[5]. ignoring.
t/03_output.t: t/torture.pod: cannot resolve L in paragraph $para[6].
t/03_output.t: t/torture.pod: unterminated list(s) at =head in paragraph $para[7]. ignoring.
EOM
chomp $error_message;
stderr_is( sub {pod2html('--infile=t/torture.pod', '--outfile=t/torture.out')},
<-, not STDOUT';
stdout_is( sub {pod2html(
'--infile=t/noheads.pod',
)}, slurp('t/noheads.html'), 'direct STDOUT'
);
};
sub slurp {
my $file = shift;
open my $in, $file or die "cannot open $file for input: $!";
local $/ = undef;
my $rec = <$in>;
close $in;
return $rec;
}