2 # $Id: parselink.t,v 1.1 2001/11/23 10:09:06 eagle Exp $
4 # parselink.t -- Tests for Pod::ParseLink.
6 # Copyright 2001 by Russ Allbery <rra@stanford.edu>
8 # This program is free software; you may redistribute it and/or modify it
9 # under the same terms as Perl itself.
11 # The format of each entry in this array is the L<> text followed by the
12 # five-element parse returned by parselink. When adding a new test, also
13 # increment the test count in the BEGIN block below. We don't use any of the
14 # fancy test modules intentionally for backward compatibility to older
18 undef, 'foo', 'foo', undef, 'pod' ],
21 'foo', 'foo', 'bar', undef, 'pod' ],
24 undef, '"bar" in foo', 'foo', 'bar', 'pod' ],
27 undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod' ],
30 undef, '"bar"', undef, 'bar', 'pod' ],
33 undef, '"baz boo"', undef, 'baz boo', 'pod' ],
36 undef, '"baz boo"', undef, 'baz boo', 'pod' ],
39 undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
41 [ 'foo bar / baz boo',
42 undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
44 [ "foo\nbar\nbaz\n/\nboo",
45 undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod' ],
47 [ 'anchor|name/section',
48 'anchor', 'anchor', 'name', 'section', 'pod' ],
51 undef, '"boo var baz"', undef, 'boo var baz', 'pod' ],
54 undef, '"bar baz"', undef, 'bar baz', 'pod' ],
56 [ '"boo bar baz / baz boo"',
57 undef, '"boo bar baz / baz boo"', undef, 'boo bar baz / baz boo',
61 undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod' ],
63 [ 'Testing I<italics>|foo/bar',
64 'Testing I<italics>', 'Testing I<italics>', 'foo', 'bar', 'pod' ],
66 [ 'foo/I<Italic> text',
67 undef, '"I<Italic> text" in foo', 'foo', 'I<Italic> text', 'pod' ],
69 [ 'fooE<verbar>barZ<>/Section C<with> I<B<other> markup',
70 undef, '"Section C<with> I<B<other> markup" in fooE<verbar>barZ<>',
71 'fooE<verbar>barZ<>', 'Section C<with> I<B<other> markup', 'pod' ],
73 [ 'Nested L<http://www.perl.org/>|fooE<sol>bar',
74 'Nested L<http://www.perl.org/>', 'Nested L<http://www.perl.org/>',
75 'fooE<sol>bar', undef, 'pod' ],
78 undef, 'ls(1)', 'ls(1)', undef, 'man' ],
80 [ ' perlfunc(1)/open ',
81 undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man' ],
83 [ 'some manual page|perl(1)',
84 'some manual page', 'some manual page', 'perl(1)', undef, 'man' ],
86 [ 'http://www.perl.org/',
87 undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, 'url' ],
89 [ 'news:yld72axzc8.fsf@windlord.stanford.edu',
90 undef, 'news:yld72axzc8.fsf@windlord.stanford.edu',
91 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ]
96 unshift (@INC, '../blib/lib');
102 print "not ok 1\n" unless $loaded;
109 # Used for reporting test failures.
110 my @names = qw(text inferred name section type);
115 my $link = shift @expected;
116 my @results = parselink ($link);
119 # Make sure to check undef explicitly; we don't want undef to match
120 # the empty string because they're semantically different.
121 unless ((!defined ($results[$_]) && !defined ($expected[$_]))
122 || (defined ($results[$_]) && defined ($expected[$_])
123 && $results[$_] eq $expected[$_])) {
124 print "not ok $n\n" if $okay;
125 print "# Incorrect $names[$_]:\n";
126 print "# expected: $expected[$_]\n";
127 print "# seen: $results[$_]\n";
131 print "ok $n\n" if $okay;