1#!/usr/bin/perl 2 3# This tests Pod::Checker::Hyperlink 4 5use Test::More; 6use Pod::Checker; 7 8my @answers = ( 9 { 10 'line' => 12, 11 'node' => 'section', 12 'page' => 'manpage', 13 'type' => 'pod' 14 }, 15 { 16 'line' => 14, 17 'node' => 'section', 18 'page' => '"manpage"', 19 'type' => 'pod', 20 }, 21 { 22 'line' => 16, 23 'node' => 'section', 24 'page' => 'manpage', 25 'type' => 'pod', 26 }, 27 { 28 'line' => 20, 29 'node' => 'section', 30 'page' => 'manpage', 31 'type' => 'pod', 32 }, 33 { 34 'line' => 22, 35 'node' => 'section', 36 'page' => 'manpage', 37 'type' => 'pod', 38 }, 39 { 40 'line' => 24, 41 'node' => 'section', 42 'page' => 'manpage', 43 'type' => 'pod', 44 }, 45 { 46 'line' => 26, 47 'node' => 'section', 48 'page' => 'manpage', 49 'type' => 'pod', 50 }, 51 { 52 'line' => 28, 53 'node' => 'section', 54 'page' => 'manpage', 55 'type' => 'pod', 56 }, 57 { 58 'line' => 30, 59 'node' => 'section', 60 'page' => 'manpage', 61 'type' => 'pod', 62 }, 63 { 64 'line' => 36, 65 'node' => '', 66 'page' => 'foo', 67 'type' => 'pod', 68 }, 69 { 70 'line' => 38, 71 'node' => '', 72 'page' => 'bar', 73 'type' => 'pod' 74 }, 75 { 76 'line' => 40, 77 'node' => 'bar', 78 'page' => 'foo', 79 'type' => 'pod' 80 }, 81 { 82 'line' => 42, 83 'node' => 'baz boo', 84 'page' => 'foo', 85 'type' => 'pod' 86 }, 87 { 88 'line' => 50, 89 'node' => 'baz boo', 90 'page' => 'foo bar', 91 'type' => 'pod', 92 }, 93 { 94 'line' => 59, 95 'node' => '', 96 'page' => 'foobar', 97 'type' => 'pod', 98 }, 99 { 100 'line' => 61, 101 'node' => 'bar', 102 'page' => 'foo', 103 'type' => 'pod' 104 }, 105 { 106 'line' => 63, 107 'node' => 'Italic text', 108 'page' => 'foo', 109 'type' => 'pod' 110 }, 111 { 112 'line' => 65, 113 'node' => 'Section with other markup', 114 'page' => 'foo|bar', 115 'type' => 'pod', 116 }, 117 { 118 'line' => 67, 119 'node' => '', 120 'page' => 'chmod', 121 'type' => 'pod', 122 }, 123 { 124 'line' => 69, 125 'node' => '', 126 'page' => 'chmod(2)', 127 'type' => 'man', 128 }, 129 { 130 'line' => 71, 131 'node' => '', 132 'page' => 'chmod(2)', 133 'type' => 'man', 134 }, 135 { 136 'line' => 73, 137 'node' => '', 138 'page' => 'chmod()', 139 'type' => 'pod', 140 }, 141 { 142 'line' => 75, 143 'node' => '', 144 'page' => 'mailto:foo@cpan.org', 145 'type' => 'url', 146 }, 147 { 148 'line' => 77, 149 'node' => '', 150 'page' => 'mailto:foo@cpan.org', 151 'type' => 'url', 152 }, 153 { 154 'line' => 79, 155 'node' => '', 156 'page' => 'http://www.perl.org', 157 'type' => 'url', 158 }, 159 { 160 'line' => 81, 161 'node' => '', 162 'page' => 'http://www.perl.org', 163 'type' => 'url', 164 }, 165 ); 166 167plan 'tests' => @answers * 4 + 2; 168 169my $checker = Pod::Checker->new( '-quiet' => 1); 170$checker->parse_from_file(\*DATA); 171 172is($checker->num_warnings, 0, "There were no warnings found"); 173is($checker->num_errors, 0, "There were no errors found"); 174 175my @links = $checker->hyperlinks; 176 177for my $i (0 .. @links - 1) { 178 is($links[$i]->line(), $answers[$i]->{'line'}, "line() returns '$answers[$i]->{'line'}' correctly"); 179 is($links[$i]->node(), $answers[$i]->{'node'}, "node() returns '$answers[$i]->{'node'}' correctly"); 180 is($links[$i]->page(), $answers[$i]->{'page'}, "page() returns '$answers[$i]->{'page'}' correctly"); 181 is($links[$i]->type(), $answers[$i]->{'type'}, "type() returns '$answers[$i]->{'type'}' correctly"); 182} 183 184__END__ 185 186=head1 NAME 187 188basic.pod - Extracted and expanded from podlators; test various link types 189 190=head1 LINKS 191 192These are all taken from the Pod::Parser tests. 193 194Try out I<LOTS> of different ways of specifying references: 195 196Reference the L<manpage/section> 197 198Reference the L<"manpage"/section> 199 200Reference the L<manpage/"section"> 201 202Now try it using the new "|" stuff ... 203 204Reference the L<thistext|manpage/section>| 205 206Reference the L<thistext | manpage / section>| 207 208Reference the L<thistext| manpage/ section>| 209 210Reference the L<thistext |manpage /section>| 211 212Reference the L<thistext|manpage/"section">| 213 214Reference the L<thistext| 215manpage/ 216section>| 217 218And then throw in a few new ones of my own. 219 220L<foo> 221 222L<foo|bar> 223 224L<foo/bar> 225 226L<foo/"baz boo"> 227 228L</bar> won't show up because is a link to this page 229 230L</"baz boo"> won't show up because is a link to this page 231 232L</baz boo> won't show up because is a link to this page 233 234L<foo bar/baz boo> 235 236L<"boo var baz"> won't show up because the quotes make it a link to this page 237 238L<bar baz> won't show up because of blanks (deprecated) make it a link to this 239page 240 241L</boo>, L</bar>, and L</baz> won't show up because are links to this page 242 243L<fooZ<>bar> 244 245L<Testing I<italics>|foo/bar> 246 247L<foo/I<Italic> text> 248 249L<fooE<verbar>barZ<>/Section C<with> I<B<other> markup>> 250 251L<chmod> 252 253L<chmod(2)> 254 255L<man page with text|chmod(2)> 256 257L<chmod()> 258 259L<mailto:foo@cpan.org> 260 261L<Don't email us|mailto:foo@cpan.org> 262 263L<http://www.perl.org> 264 265L<hyperlink|http://www.perl.org> 266 267=head1 bar 268 269=head2 baz boo 270 271=head3 boo var baz 272 273=head4 bar baz 274 275=cut 276