This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: savepv() of getenv()
[perl5.git] / cpan / Pod-Simple / t / whine.t
CommitLineData
b5ae6e74
CBW
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 my @errors;
10 sub whine {
11 my ($self, @rest) = @_;
12 push @errors, [ @rest ];
13 $self->SUPER::whine(@rest);
14 }
15
16 sub scream {
17 my ($self, @rest) = @_;
18 push @errors, [ @rest ];
19 $self->SUPER::scream(@rest);
20 }
21
22 sub errors_for_input {
23 my ($class, $input, $mutor) = @_;
24 @errors = ();
25
26 my $parser = $class->new;
27 my $output = '';
28 $parser->output_string( \$output );
29 $parser->parse_string_document( $input );
30
31 @errors = sort { $a->[0] <=> $b->[0]
32 || $a->[1] cmp $b->[1] } @errors;
33
34 return @errors;
35 }
36}
37
38sub errors { Pod::Simple::ErrorFinder->errors_for_input(@_) }
39
40{
41 my @errors = errors("=over 4\n\n=item 1\n\nHey\n\n");
42 is_deeply(
43 \@errors,
44 [ [ 1, "=over without closing =back" ] ],
45 "no closing =back",
46 );
47}
48
49{
50 for my $l_code ('L< foo>', 'L< bar>') {
51 my $input = "=pod\n\nAmbiguous space: $l_code\n";
52 my @errors = errors("$input");
53 is_deeply(
54 \@errors,
55 [ [ 3, "L<> starts or ends with whitespace" ] ],
56 "warning for space in $l_code",
57 );
58 }
59}
60
61{
62 my $input = "=pod\n\nAmbiguous slash: L<I/O Operators|op/io>\n";
63 my @errors = errors("$input");
64 is_deeply(
65 \@errors,
66 [ [ 3, "alternative text 'I/O Operators' contains non-escaped | or /" ] ],
67 "warning for / in text part of L<>",
68 );
69}