File: filter.t

package info (click to toggle)
libpod-simple-perl 3.47-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,760 kB
  • sloc: perl: 7,073; xml: 2,427; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
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
use strict;
use warnings;
use Test::More;
use Pod::Simple::JustPod;

sub convert {
  my ($pod, $select) = @_;

  my $out = '';
  my $parser = Pod::Simple::JustPod->new;
  $parser->output_string(\$out);
  $parser->set_heading_select(@$select);

  $parser->parse_string_document($pod);
  return $out;
}

sub compare {
  my ($in, $want, $select, $name) = @_;
  for my $pod ($in, $want) {
    if ($pod =~ /\A([\t ]+)/) {
      my $prefix = $1;
      $pod =~ s{^$prefix}{}gm;
    }
  }
  my $got = convert($in, $select);
  $got =~ s/\A=pod\n\n//;
  local $Test::Builder::Level = $Test::Builder::Level + 1;
  is $got, $want, $name;
}

compare <<'END_IN_POD', <<'END_OUT_POD', [ 'DESCRIPTION/guff' ];
  =head1 NAME

  NAME content

  =head2 welp

  welp content

  =head3 hork

  hork content

  =head1 DESCRIPTION

  DESCRIPTION content

  =head2 guff

  guff content

  =cut
END_IN_POD
  =head2 guff

  guff content

  =cut
END_OUT_POD

done_testing;