1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
use strict;
use Test::More;
use Pandoc::Elements;
use Pandoc;
use Pod::Simple::Pandoc;
use Pod::Pandoc::Modules;
use Test::Exception;
plan skip_all => 'pandoc not available' unless pandoc;
my $parser = Pod::Simple::Pandoc->new;
# add
{
my $modules = Pod::Pandoc::Modules->new;
my $name = 'Pod::Simple::Pandoc';
my $file = $ENV{AUTOPKGTEST_TMP} ? '/usr/share/perl5/Pod/Simple/Pandoc.pm' : 'lib/Pod/Simple/Pandoc.pm';
my $doc = $parser->parse_file($file);
ok $modules->add( $name => $doc ), 'add';
is $modules->{$name}, $doc, 'added';
my $script = $ENV{AUTOPKGTEST_TMP} ? '/usr/bin/pod2pandoc' : 'script/pod2pandoc';
ok !$modules->add( $name => $parser->parse_file($script) );
is $modules->{$name}, $doc, 'add doesn\'t override';
$file = 't/examples/Pandoc.pod';
ok $modules->add( $name => $parser->parse_file($file) ), 'add';
is $modules->{$name}->metavalue('file'), $file, '.pod overrides .pm';
is $modules->{$name}->metavalue('title'), $name, 'title without NAME';
}
# constructor
my $file = $ENV{AUTOPKGTEST_TMP} ? '/usr/share/perl5/Pod/Simple/Pandoc.pm' : 'lib/Pod/Simple/Pandoc.pm';
my $modules = Pod::Pandoc::Modules->new({
'Pod::Simple::Pandoc' => $parser->parse_file($file)
});
# index
sub is_index {
my ( $name, $opt, $meta, $url, $title ) = @_;
is_deeply $modules->index(%$opt),
Document( $meta, [
DefinitionList [ [
[
Link attributes {},
[ Str 'Pod::Simple::Pandoc' ],
[ $url, $title ]
],
[ [ Plain [ Str 'convert Pod to Pandoc document model' ] ] ]
] ]
]), $name;
}
is_index(
'index (default)',
{}, {},
'Pod-Simple-Pandoc.html', 'Pod::Simple::Pandoc'
);
is_index(
'index (wiki & title)',
{ wiki => 1, title => 'test' }, { title => MetaString 'test' },
'Pod-Simple-Pandoc', 'wikilink'
);
done_testing;
|