summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/cpan/Pod-Simple/t/whine.t
blob: 4ac76e5bd3dbba45ef5c3790eff1e3afdb112634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use strict;
use warnings;
use Test::More tests => 6;

{
  package Pod::Simple::ErrorFinder;
  use base 'Pod::Simple::DumpAsXML'; # arbitrary choice -- rjbs, 2013-04-16

  sub errors_for_input {
    my ($class, $input, $mutor) = @_;

    my $parser = $class->new;
    my $output = '';
    $parser->output_string( \$output );
    $parser->no_errata_section(1);
    $parser->parse_string_document( $input );

    return $parser->errata_seen();
  }
}

sub errors { Pod::Simple::ErrorFinder->errors_for_input(@_) }

{
  my $errors = errors("=over 4\n\n=item 1\n\nHey\n\n");
  is_deeply(
    $errors,
    { 1 => [ "=over without closing =back" ] },
    "no closing =back",
  );
}

{
  for my $l_code ('L< foo>', 'L< bar>') {
    my $input = "=pod\n\nAmbiguous space: $l_code\n";
    my $errors = errors("$input");
    is_deeply(
      $errors,
      { 3 => [ "L<> starts or ends with whitespace" ] },
      "warning for space in $l_code",
    );
  }
}

{
  my $input = "=pod\n\nAmbiguous slash: L<I/O Operators|op/io>\n";
  my $errors = errors("$input");
  is_deeply(
    $errors,
    { 3 => [ "alternative text 'I/O Operators' contains non-escaped | or /" ] },
    "warning for / in text part of L<>",
  );
}

{
  my $input = "=pod\n\nnested LE<lt>E<sol>E<gt>: L<Nested L<http://foobar>|http://baz>\n";
  my $errors = errors("$input");
  is_deeply(
    $errors,
    { 3 => [ "Nested L<> are illegal.  Pretending inner one is X<...> so can continue looking for other errors." ] },
      "warning for nested L<>",
  );
}
    
{
  my $input = "=pod\n\nLE<lt>E<sol>E<gt> containing only slash: L< / >\n";
  my $errors = errors("$input");
  is_deeply(
    $errors,
    { 3 => [ "L<> contains only '/'" ] },
      "warning for L< / > containing only a slash",
  );
}