Skip to content

Commit

Permalink
Merge pull request #44 from rjbs/master
Browse files Browse the repository at this point in the history
Issue a warning when =item types mismatch within one =over/=back.
  • Loading branch information
theory committed Feb 13, 2013
2 parents e07b57a + e2bb6fe commit 1fe5991
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 45 deletions.
8 changes: 8 additions & 0 deletions lib/Pod/Simple/BlackBox.pm
Expand Up @@ -663,6 +663,10 @@ sub _ponder_paragraph_buffer {
} elsif($item_type eq 'number' or $item_type eq 'bullet') {
die "Unknown item type $item_type"
unless $item_type eq 'number' or $item_type eq 'bullet';
$self->whine(
$para->[1]{'start_line'},
"Expected text matching /\\s+[^\\*\\d]/ after '=item'"
);
# Undo our clobbering:
push @$para, $para->[1]{'~orig_content'};
delete $para->[1]{'number'};
Expand Down Expand Up @@ -1271,6 +1275,10 @@ sub _ponder_item {
} elsif($item_type eq 'number' or $item_type eq 'bullet') {
die "Unknown item type $item_type"
unless $item_type eq 'number' or $item_type eq 'bullet';
$self->whine(
$para->[1]{'start_line'},
"Expected text matching /\\s+[^\\*\\d]/ after '=item'"
);
# Undo our clobbering:
push @$para, $para->[1]{'~orig_content'};
delete $para->[1]{'number'};
Expand Down
4 changes: 3 additions & 1 deletion t/items.t
Expand Up @@ -91,7 +91,9 @@ ok( $x->_out("\n=over\n\n=item Foo\n\n Stuff\n\tSnork\n=cut\n\nCrunk\nZorp\n\n=i


print "#\n# Test for mixed =item blocks...\n";
ok( $x->_out("\n=over\n\n=item Foo\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\nQuux\n\n=item *\n\nThwoong\n\n=back\n\n"),
ok( $x->_out(
sub { $_[0]->no_errata_section(1) }, # We know this will complain
"\n=over\n\n=item Foo\n\nStuff\n\n=item 2.\n\nBar I<baz>!\n\nQuux\n\n=item *\n\nThwoong\n\n=back\n\n"),
qq{<Document><over-text indent="4"><item-text>Foo</item-text><Para>Stuff</Para>}
. qq{<item-text>2.</item-text><Para>Bar <I>baz</I>!</Para><Para>Quux</Para>}
. qq{<item-text>*</item-text><Para>Thwoong</Para></over-text></Document>}
Expand Down
90 changes: 46 additions & 44 deletions t/items02.t
@@ -1,44 +1,46 @@
# Testing the =item directive
BEGIN {
if($ENV{PERL_CORE}) {
chdir 't';
@INC = '../lib';
}
}

use strict;
use Test;
BEGIN { plan tests => 4 };

my $d;
#use Pod::Simple::Debug (\$d,0);

ok 1;

use Pod::Simple::DumpAsXML;
use Pod::Simple::XMLOutStream;
print "# Pod::Simple version $Pod::Simple::VERSION\n";
sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }

my $x = 'Pod::Simple::XMLOutStream';

print "##### Tests for =item directives via class $x\n";

$Pod::Simple::XMLOutStream::ATTR_PAD = ' ';
$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output


print "#\n# Tests for =item [number] that are icky...\n";
ok( $x->_out("\n=over\n\n=item 5\n\nStuff\n\n=cut\n\nCrunk\nZorp\n\n=item 4\n\nQuux\n\n=back\n\n"),
'<Document><over-text indent="4"><item-text>5</item-text><Para>Stuff</Para><item-text>4</item-text><Para>Quux</Para></over-text></Document>'
);

ok( $x->_out("\n=over\n\n=item 5.\n\nStuff\n\n=cut\n\nCrunk\nZorp\n\n=item 4.\n\nQuux\n\n=back\n\n"),
'<Document><over-text indent="4"><item-text>5.</item-text><Para>Stuff</Para><item-text>4.</item-text><Para>Quux</Para></over-text></Document>'
);


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

# Testing the =item directive
BEGIN {
if($ENV{PERL_CORE}) {
chdir 't';
@INC = '../lib';
}
}

use strict;
use Test;
BEGIN { plan tests => 4 };

my $d;
#use Pod::Simple::Debug (\$d,0);

ok 1;

use Pod::Simple::DumpAsXML;
use Pod::Simple::XMLOutStream;
print "# Pod::Simple version $Pod::Simple::VERSION\n";
sub e ($$) { Pod::Simple::DumpAsXML->_duo(@_) }

my $x = 'Pod::Simple::XMLOutStream';

print "##### Tests for =item directives via class $x\n";

$Pod::Simple::XMLOutStream::ATTR_PAD = ' ';
$Pod::Simple::XMLOutStream::SORT_ATTRS = 1; # for predictably testable output


print "#\n# Tests for =item [number] that are icky...\n";
ok( $x->_out(sub { $_[0]->no_errata_section(1) },
"\n=over\n\n=item 5\n\nStuff\n\n=cut\n\nCrunk\nZorp\n\n=item 4\n\nQuux\n\n=back\n\n"),
'<Document><over-text indent="4"><item-text>5</item-text><Para>Stuff</Para><item-text>4</item-text><Para>Quux</Para></over-text></Document>'
);

ok( $x->_out(sub { $_[0]->no_errata_section(1) },
"\n=over\n\n=item 5.\n\nStuff\n\n=cut\n\nCrunk\nZorp\n\n=item 4.\n\nQuux\n\n=back\n\n"),
'<Document><over-text indent="4"><item-text>5.</item-text><Para>Stuff</Para><item-text>4.</item-text><Para>Quux</Para></over-text></Document>'
);


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

0 comments on commit 1fe5991

Please sign in to comment.