This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #113926] fix a hash randomization bug
[perl5.git] / ext / Pod-Html / t / anchorify.t
CommitLineData
1022acf4
JK
1# -*- perl -*-
2use strict;
3use Pod::Html qw( anchorify );
4use Test::More tests => 1;
5
6my @filedata;
7{
8 local $/ = '';
9 @filedata = <DATA>;
10}
11
12my (@poddata, $i, $j);
13for ($i = 0, $j = -1; $i <= $#filedata; $i++) {
14 $j++ if ($filedata[$i] =~ /^\s*=head[1-6]/);
15 if ($j >= 0) {
16 $poddata[$j] = "" unless defined $poddata[$j];
17 $poddata[$j] .= "\n$filedata[$i]" if $j >= 0;
18 }
19}
20
21my %heads = ();
22foreach $i (0..$#poddata) {
23 $heads{anchorify($1)} = 1 if $poddata[$i] =~ /=head[1-6]\s+(.*)/;
24}
25my %expected = map { $_ => 1 } qw(
26 name
27 description
28 subroutine
29 error
30 method
31 has_a_wordspace
32 hastrailingwordspace
33 hasleadingwordspace
34 has_extra_internalwordspace
35 hasquotes
36 hasquestionmark
37 has_hyphen_and_space
38);
39is_deeply(
07be00e8
TC
40 \%heads,
41 \%expected,
1022acf4
JK
42 "Got expected POD heads"
43);
44
45__DATA__
46=head1 NAME
47
48anchorify - Test C<Pod::Html::anchorify()>
49
50=head1 DESCRIPTION
51
52alpha
53
54=head2 Subroutine
55
56beta
57
58=head3 Error
59
60gamma
61
62=head4 Method
63
64delta
65
66=head4 Has A Wordspace
67
68delta
69
70=head4 HasTrailingWordspace
71
72epsilon
73
74=head4 HasLeadingWordspace
75
76zeta
77
78=head4 Has Extra InternalWordspace
79
80eta
81
82=head4 Has"Quotes"
83
84theta
85
86=head4 Has?QuestionMark
87
88iota
89
90=head4 Has-Hyphen And Space
91
92kappa
93
94=cut
95
96__END__