1use strict; 2use warnings; 3use Test::More tests => 6; 4 5{ 6 package Pod::Simple::ErrorFinder; 7 use base 'Pod::Simple::DumpAsXML'; # arbitrary choice -- rjbs, 2013-04-16 8 9 sub errors_for_input { 10 my ($class, $input, $mutor) = @_; 11 12 my $parser = $class->new; 13 my $output = ''; 14 $parser->output_string( \$output ); 15 $parser->no_errata_section(1); 16 $parser->parse_string_document( $input ); 17 18 return $parser->errata_seen(); 19 } 20} 21 22sub errors { Pod::Simple::ErrorFinder->errors_for_input(@_) } 23 24{ 25 my $errors = errors("=over 4\n\n=item 1\n\nHey\n\n"); 26 is_deeply( 27 $errors, 28 { 1 => [ "=over without closing =back" ] }, 29 "no closing =back", 30 ); 31} 32 33{ 34 for my $l_code ('L< foo>', 'L< bar>') { 35 my $input = "=pod\n\nAmbiguous space: $l_code\n"; 36 my $errors = errors("$input"); 37 is_deeply( 38 $errors, 39 { 3 => [ "L<> starts or ends with whitespace" ] }, 40 "warning for space in $l_code", 41 ); 42 } 43} 44 45{ 46 my $input = "=pod\n\nAmbiguous slash: L<I/O Operators|op/io>\n"; 47 my $errors = errors("$input"); 48 is_deeply( 49 $errors, 50 { 3 => [ "alternative text 'I/O Operators' contains non-escaped | or /" ] }, 51 "warning for / in text part of L<>", 52 ); 53} 54 55{ 56 my $input = "=pod\n\nnested LE<lt>E<sol>E<gt>: L<Nested L<http://foobar>|http://baz>\n"; 57 my $errors = errors("$input"); 58 is_deeply( 59 $errors, 60 { 3 => [ "Nested L<> are illegal. Pretending inner one is X<...> so can continue looking for other errors." ] }, 61 "warning for nested L<>", 62 ); 63} 64 65{ 66 my $input = "=pod\n\nLE<lt>E<sol>E<gt> containing only slash: L< / >\n"; 67 my $errors = errors("$input"); 68 is_deeply( 69 $errors, 70 { 3 => [ "L<> contains only '/'" ] }, 71 "warning for L< / > containing only a slash", 72 ); 73} 74