| 1 | # -*- perl -*- |
| 2 | use strict; |
| 3 | use Pod::Html qw( anchorify ); |
| 4 | use Test::More tests => 1; |
| 5 | |
| 6 | my @filedata; |
| 7 | { |
| 8 | local $/ = ''; |
| 9 | @filedata = <DATA>; |
| 10 | } |
| 11 | |
| 12 | my (@poddata, $i, $j); |
| 13 | for ($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 | |
| 21 | my %heads = (); |
| 22 | foreach $i (0..$#poddata) { |
| 23 | $heads{anchorify($1)} = 1 if $poddata[$i] =~ /=head[1-6]\s+(.*)/; |
| 24 | } |
| 25 | my %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 | ); |
| 39 | is_deeply( |
| 40 | \%heads, |
| 41 | \%expected, |
| 42 | "Got expected POD heads" |
| 43 | ); |
| 44 | |
| 45 | __DATA__ |
| 46 | =head1 NAME |
| 47 | |
| 48 | anchorify - Test C<Pod::Html::anchorify()> |
| 49 | |
| 50 | =head1 DESCRIPTION |
| 51 | |
| 52 | alpha |
| 53 | |
| 54 | =head2 Subroutine |
| 55 | |
| 56 | beta |
| 57 | |
| 58 | =head3 Error |
| 59 | |
| 60 | gamma |
| 61 | |
| 62 | =head4 Method |
| 63 | |
| 64 | delta |
| 65 | |
| 66 | =head4 Has A Wordspace |
| 67 | |
| 68 | delta |
| 69 | |
| 70 | =head4 HasTrailingWordspace |
| 71 | |
| 72 | epsilon |
| 73 | |
| 74 | =head4 HasLeadingWordspace |
| 75 | |
| 76 | zeta |
| 77 | |
| 78 | =head4 Has Extra InternalWordspace |
| 79 | |
| 80 | eta |
| 81 | |
| 82 | =head4 Has"Quotes" |
| 83 | |
| 84 | theta |
| 85 | |
| 86 | =head4 Has?QuestionMark |
| 87 | |
| 88 | iota |
| 89 | |
| 90 | =head4 Has-Hyphen And Space |
| 91 | |
| 92 | kappa |
| 93 | |
| 94 | =cut |
| 95 | |
| 96 | __END__ |