File: back-compat.t

package info (click to toggle)
libpod-markdown-perl 3.101000-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 444 kB
  • sloc: perl: 1,000; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download | duplicates (5)
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
69
# vim: set ts=2 sts=2 sw=2 expandtab smarttab:
use strict;
use warnings;
use lib 't/lib';
use MarkdownTests;
use File::Spec ();

# Explicitly test using a real file.
my $_pod_path = File::Spec->catfile(qw(corpus tinypod.txt));
my $_pod_text = "This is _pod_.";

sub compare {
  my ($got, $exp, $desc) = @_;
  chomp $got;
  eq_or_diff $got, $exp, $desc;
}

# NOTE: With Pod::Parser apparently as_markdown would return
# strings with html-encoded entities and no utf8 flag.
# We could add that functionality into the parse_file/as_markdown subs
# if needed, but it's been based on Pod::Simple for over a year so far
# with no reports so it likely isn't (needed).

# Dist::Zilla::Plugin::ReadmeAnyFromPod
SKIP: {
  eval 'require IO::Scalar'
    or skip 'IO::Scalar not available for testing.', 1;

  my $pod = "=pod\n\nB<foo>\n";

  my $parser = Pod::Markdown->new();

  my $input_handle = IO::Scalar->new(\$pod);

  $parser->parse_from_filehandle($input_handle);
  my $content = $parser->as_markdown();

  compare $content, '**foo**',
    'parse_from_filehandle( IO::Scalar->new(\$string) )';
}

# Minilla
# Module::Build::Pluggable::ReadmeMarkdownFromPod
# Module::Install::ReadmeMarkdownFromPod
{
  my $readme_from = $_pod_path;

  my $parser = Pod::Markdown->new;
  $parser->parse_from_file($readme_from);

  my $markdown = $parser->as_markdown;

  compare $markdown, $_pod_text,
    'parse_from_file( $path )';
}

{
  my $pod = $_pod_path;

  open my $pod_fh, '<', $pod        or die "Can't read POD '$pod'";

  my $md = Pod::Markdown->new;
  $md->parse_from_filehandle($pod_fh);

  compare $md->as_markdown, $_pod_text,
    'parse_from_filehandle( open(my) )';
}

done_testing;