summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/Pod-Simple/t/fake-closers.t
blob: 07f806587f834f761a89ef9a945716274839110f (plain) (blame)
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
70
71
BEGIN {
    if($ENV{PERL_CORE}) {
        chdir 't';
        @INC = '../lib';
    }
}

use strict;
use Test::More;
use Data::Dumper;
BEGIN { plan tests => 9 };

ok 1;

my $i = 0;

print "# Real closers ...\n";

for my $pod ( "=over\n\nblock\n\n=back",
              "=over\n\nblock\n\n=cut\n\ncode\n\n=pod\n\n=back",
              "=begin html\n\ntag\n\n=end html",
              ) {
    my $parser = Pod::Simple::Blurb->new();
    $parser->parse_string_document($pod);
    is($parser->{'closer-flag'}, -1, "real closer ". ++$i);
}

$i = 0;

print "# Fake closers ...\n";

for my $pod ("=begin html\n\ntag=cut",
             "=begin html\n\ntag\n\n=begin xml tag =end xml",
             "=over\n\nblock=cut",
             "=over\n\nanother block",
              ) {
    my $parser = Pod::Simple::Blurb->new();
    $parser->parse_string_document($pod);
    is($parser->{'closer-flag'}, 1, "fake closer ". ++$i);
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

print "# Wrapping up... one for the road...\n";
ok 1;
print "# --- Done with ", __FILE__, " --- \n";

1;

package Pod::Simple::Blurb;
use warnings;
use strict;
use base qw/Pod::Simple::Methody/;

sub new {
    my $new = shift->SUPER::new(@_);
    $new->output_string(\my $doesnotmatter);
    $new->accept_targets('*');
    return $new;
}

sub end_over_block {
    shift->set(@_);
}
sub end_for {
    shift->set(@_);
}

sub set {
    $_[0]{'closer-flag'} = defined $_[1]{'fake-closer'} ? 1 : -1;
}