xref: /openbsd-src/gnu/usr.bin/perl/cpan/Pod-Simple/t/output.t (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1# t/output.t - Check output_string.
2#
3use strict;
4use warnings;
5use Test::More tests => 36;
6
7use File::Spec;
8use Cwd ();
9use File::Basename ();
10
11my $t_dir = File::Basename::dirname(Cwd::abs_path(__FILE__));
12
13for my $format (qw(XHTML HTML Text RTF)) {
14    my $class = "Pod::Simple::$format";
15    use_ok $class or next;
16    ok my $parser = $class->new, "Construct $format parser";
17
18    # Try parse_string_document().
19    my $output = '';
20    ok $parser->output_string(\$output), "Set $format output string";
21    ok $parser->parse_string_document( "=head1 Poit!" ),
22        "Parse to $format via parse_string_document()";
23    like $output, qr{Poit!},
24        "Should have $format output from parse_string_document()";
25
26    # Try parse_file().
27    ok $parser = $class->new, "Construct another $format parser";
28    $output = '';
29    ok $parser->output_string(\$output), "Set $format output string again";
30    ok $parser->parse_file(File::Spec->catfile($t_dir, qw(testlib1 zikzik.pod))),
31        "Parse to $format via parse_file()";
32    like $output, qr{This is just a test file},
33        "Should have $format output from parse_file";
34}
35