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 Has_Quotes 36 Has_QuestionMark 37 Has_Hyphen_And_Space 38); 39is_deeply( 40 \%heads, 41 \%expected, 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__ 97