Permalink
Browse files

Merge pull request #44 from rjbs/master

Issue a warning when =item types mismatch within one =over/=back.
  • Loading branch information...
2 parents e07b57a + e2bb6fe commit 1fe599178c979bd31838eaa52b120591890c73fa @theory committed Feb 13, 2013
Showing with 57 additions and 45 deletions.
  1. +8 −0 lib/Pod/Simple/BlackBox.pm
  2. +3 −1 t/items.t
  3. +46 −44 t/items02.t
@@ -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'};
@@ -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'};
View
@@ -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>}
View
@@ -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.