1use strict; 2use warnings; 3use Test::More tests => 4; 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