File: fake-closers.t

package info (click to toggle)
perl 5.40.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 126,152 kB
  • sloc: ansic: 668,539; perl: 525,522; sh: 72,038; pascal: 6,925; xml: 2,428; yacc: 1,410; makefile: 1,191; cpp: 208; lisp: 1
file content (54 lines) | stat: -rw-r--r-- 1,209 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More tests => 7;
use Data::Dumper;

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);
}

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;
}