3 # parselink.t -- Tests for Pod::ParseLink.
5 # Copyright 2001, 2009 by Russ Allbery <rra@stanford.edu>
7 # This program is free software; you may redistribute it and/or modify it
8 # under the same terms as Perl itself.
10 # The format of each entry in this array is the L<> text followed by the
11 # five-element parse returned by parselink.
14 undef, 'foo', 'foo', undef, 'pod' ],
17 'foo', 'foo', 'bar', undef, 'pod' ],
20 undef, '"bar" in foo', 'foo', 'bar', 'pod' ],
23 undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod' ],
26 undef, '"bar"', undef, 'bar', 'pod' ],
29 undef, '"baz boo"', undef, 'baz boo', 'pod' ],
32 undef, '"baz boo"', undef, 'baz boo', 'pod' ],
35 undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
37 [ 'foo bar / baz boo',
38 undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
40 [ "foo\nbar\nbaz\n/\nboo",
41 undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod' ],
43 [ 'anchor|name/section',
44 'anchor', 'anchor', 'name', 'section', 'pod' ],
47 undef, '"boo var baz"', undef, 'boo var baz', 'pod' ],
50 undef, '"bar baz"', undef, 'bar baz', 'pod' ],
52 [ '"boo bar baz / baz boo"',
53 undef, '"boo bar baz / baz boo"', undef, 'boo bar baz / baz boo',
57 undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod' ],
59 [ 'Testing I<italics>|foo/bar',
60 'Testing I<italics>', 'Testing I<italics>', 'foo', 'bar', 'pod' ],
62 [ 'foo/I<Italic> text',
63 undef, '"I<Italic> text" in foo', 'foo', 'I<Italic> text', 'pod' ],
65 [ 'fooE<verbar>barZ<>/Section C<with> I<B<other> markup',
66 undef, '"Section C<with> I<B<other> markup" in fooE<verbar>barZ<>',
67 'fooE<verbar>barZ<>', 'Section C<with> I<B<other> markup', 'pod' ],
69 [ 'Nested L<http://www.perl.org/>|fooE<sol>bar',
70 'Nested L<http://www.perl.org/>', 'Nested L<http://www.perl.org/>',
71 'fooE<sol>bar', undef, 'pod' ],
74 undef, 'ls(1)', 'ls(1)', undef, 'man' ],
76 [ ' perlfunc(1)/open ',
77 undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man' ],
79 [ 'some manual page|perl(1)',
80 'some manual page', 'some manual page', 'perl(1)', undef, 'man' ],
82 [ 'http://www.perl.org/',
83 undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, 'url' ],
85 [ 'news:yld72axzc8.fsf@windlord.stanford.edu',
86 undef, 'news:yld72axzc8.fsf@windlord.stanford.edu',
87 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ],
89 [ 'link|http://www.perl.org/',
90 'link', 'link', 'http://www.perl.org/', undef, 'url' ],
92 [ '0|http://www.perl.org/',
93 '0', '0', 'http://www.perl.org/', undef, 'url' ],
96 '0', '0', 'Pod::Parser', undef, 'pod' ],
101 unshift (@INC, '../blib/lib');
107 use Test::More tests => 28;
108 BEGIN { use_ok ('Pod::ParseLink') }
110 # Used for reporting test failures.
111 my @names = qw(text inferred name section type);
115 my $link = shift @expected;
116 my @results = parselink ($link);
118 $pretty =~ s/\n/\\n/g;
119 is_deeply (\@results, \@expected, $pretty);