Commit | Line | Data |
---|---|---|
60527824 FR |
1 | BEGIN { |
2 | if($ENV{PERL_CORE}) { | |
3 | chdir 't'; | |
4 | @INC = '../lib'; | |
5 | } | |
6 | } | |
7 | ||
8 | use strict; | |
9 | use Test::More; | |
10 | use Data::Dumper; | |
11 | BEGIN { plan tests => 9 }; | |
12 | ||
13 | ok 1; | |
14 | ||
15 | my $i = 0; | |
16 | ||
17 | print "# Real closers ...\n"; | |
18 | ||
19 | for my $pod ( "=over\n\nblock\n\n=back", | |
20 | "=over\n\nblock\n\n=cut\n\ncode\n\n=pod\n\n=back", | |
21 | "=begin html\n\ntag\n\n=end html", | |
22 | ) { | |
23 | my $parser = Pod::Simple::Blurb->new(); | |
24 | $parser->parse_string_document($pod); | |
25 | is($parser->{'closer-flag'}, -1, "real closer ". ++$i); | |
26 | } | |
27 | ||
28 | $i = 0; | |
29 | ||
30 | print "# Fake closers ...\n"; | |
31 | ||
32 | for my $pod ("=begin html\n\ntag=cut", | |
33 | "=begin html\n\ntag\n\n=begin xml tag =end xml", | |
34 | "=over\n\nblock=cut", | |
35 | "=over\n\nanother block", | |
36 | ) { | |
37 | my $parser = Pod::Simple::Blurb->new(); | |
38 | $parser->parse_string_document($pod); | |
39 | is($parser->{'closer-flag'}, 1, "fake closer ". ++$i); | |
40 | } | |
41 | ||
42 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
43 | ||
44 | print "# Wrapping up... one for the road...\n"; | |
45 | ok 1; | |
46 | print "# --- Done with ", __FILE__, " --- \n"; | |
47 | ||
48 | 1; | |
49 | ||
50 | package Pod::Simple::Blurb; | |
51 | use warnings; | |
52 | use strict; | |
53 | use base qw/Pod::Simple::Methody/; | |
54 | ||
55 | sub new { | |
56 | my $new = shift->SUPER::new(@_); | |
57 | $new->output_string(\my $doesnotmatter); | |
58 | $new->accept_targets('*'); | |
59 | return $new; | |
60 | } | |
61 | ||
62 | sub end_over_block { | |
63 | shift->set(@_); | |
64 | } | |
65 | sub end_for { | |
66 | shift->set(@_); | |
67 | } | |
68 | ||
69 | sub set { | |
70 | $_[0]{'closer-flag'} = defined $_[1]{'fake-closer'} ? 1 : -1; | |
71 | } |