File: warn.t

package info (click to toggle)
libpod-pom-perl 2.01-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 800 kB
  • sloc: perl: 2,756; makefile: 7
file content (108 lines) | stat: -rw-r--r-- 2,162 bytes parent folder | download | duplicates (8)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/perl -w                                         # -*- perl -*-

use strict;
use lib qw( ./lib ../lib );
use Pod::POM::Test;
#$Pod::POM::Node::DEBUG = 1;
my $DEBUG = 1;

my $text;
{  local $/ = undef;
   $text = <DATA>;
}

ntests(27);

my ($parser, $pom, @warn, @warnings);

$parser = Pod::POM->new( );
$pom = $parser->parse_text( $text );
assert( $pom );
@warn = $parser->warnings();
match( scalar @warn, 6 );
match( $warn[0], 'over expected a terminating back at <input text> line 14' );
match( $warn[1], 'head1 expected a title at <input text> line 18' );
match( $warn[2], 'unexpected item at <input text> line 22' );
match( $warn[3], "expected '>>' not '>' at <input text> line 27" );
match( $warn[4], "unterminated 'B<<' starting at <input text> line 26" );
match( $warn[5], "spurious '>' at <input text> line 29" );

my $fullwarn1 = join("\n", @warn);

$SIG{__WARN__} = sub {
    my $msg = join('', @_);
    chomp($msg);
#    print "warning: [$msg]\n";
    push(@warnings, $msg);
};

$parser = Pod::POM->new( warn => 1 );
$pom = $parser->parse_text( $text );
assert( defined $pom );
@warn = $parser->warnings();
match( scalar @warn, 6 );
match( scalar @warnings, 6 );

foreach (@warn) {
    match( shift @warnings, $_ );
}

my $fullwarn2 = join("\n", @warn);

@warnings = ();
sub warnsub {
    my $msg = shift;
    push(@warnings, "[$msg]");
}

$parser = Pod::POM->new( warn => \&warnsub );
$pom = $parser->parse_text( $text );
assert( defined $pom );
@warn = $parser->warnings();
match( scalar @warn, 6 );
match( scalar @warnings, 6 );

foreach (@warn) {
    match( shift @warnings, "[$_]" );
}


$parser = Pod::POM->new( warn => 1 );
$pom = $parser->parse_text("=head1 Foo\n\nBlah blah");
assert( defined $pom );

#use Data::Dumper;
#$Data::Dumper::Indent=1;
#print Dumper($pom);
#print $pom;

__DATA__
=head1 NAME

A test Pod document.

=head1 DESCRIPTION

This Pod document contains errors that should raise warnings
but not fatal errors.

=over 4

=item Foo

=head1 NEXT

This is the next section.

=head1

Missing head1 title!

=item foo

This shouldn't be outside an =over!

This B<< text isn't properly terminated.
>oh dear!

Blah > Blah