Actually note that Shell.pm is deprecated for 5.13 and 5.14, so we can
[p5sagit/p5-mst-13.2.git] / cpan / podlators / t / parselink.t
CommitLineData
b616daaf 1#!/usr/bin/perl -w
b616daaf 2#
3# parselink.t -- Tests for Pod::ParseLink.
4#
fe61459e 5# Copyright 2001, 2009 by Russ Allbery <rra@stanford.edu>
b616daaf 6#
7# This program is free software; you may redistribute it and/or modify it
8# under the same terms as Perl itself.
9
10# The format of each entry in this array is the L<> text followed by the
fe61459e 11# five-element parse returned by parselink.
12our @TESTS = (
b616daaf 13 [ 'foo',
14 undef, 'foo', 'foo', undef, 'pod' ],
15
16 [ 'foo|bar',
17 'foo', 'foo', 'bar', undef, 'pod' ],
18
19 [ 'foo/bar',
20 undef, '"bar" in foo', 'foo', 'bar', 'pod' ],
21
22 [ 'foo/"baz boo"',
23 undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod' ],
24
25 [ '/bar',
26 undef, '"bar"', undef, 'bar', 'pod' ],
27
28 [ '/"baz boo"',
29 undef, '"baz boo"', undef, 'baz boo', 'pod' ],
30
31 [ '/baz boo',
32 undef, '"baz boo"', undef, 'baz boo', 'pod' ],
33
34 [ 'foo bar/baz boo',
35 undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
36
37 [ 'foo bar / baz boo',
38 undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ],
39
40 [ "foo\nbar\nbaz\n/\nboo",
41 undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod' ],
42
43 [ 'anchor|name/section',
44 'anchor', 'anchor', 'name', 'section', 'pod' ],
45
46 [ '"boo var baz"',
47 undef, '"boo var baz"', undef, 'boo var baz', 'pod' ],
48
49 [ 'bar baz',
50 undef, '"bar baz"', undef, 'bar baz', 'pod' ],
51
52 [ '"boo bar baz / baz boo"',
53 undef, '"boo bar baz / baz boo"', undef, 'boo bar baz / baz boo',
54 'pod' ],
55
56 [ 'fooZ<>bar',
57 undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod' ],
58
59 [ 'Testing I<italics>|foo/bar',
60 'Testing I<italics>', 'Testing I<italics>', 'foo', 'bar', 'pod' ],
61
62 [ 'foo/I<Italic> text',
63 undef, '"I<Italic> text" in foo', 'foo', 'I<Italic> text', 'pod' ],
64
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' ],
68
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' ],
72
73 [ 'ls(1)',
74 undef, 'ls(1)', 'ls(1)', undef, 'man' ],
75
76 [ ' perlfunc(1)/open ',
77 undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man' ],
78
79 [ 'some manual page|perl(1)',
80 'some manual page', 'some manual page', 'perl(1)', undef, 'man' ],
81
82 [ 'http://www.perl.org/',
83 undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, 'url' ],
84
85 [ 'news:yld72axzc8.fsf@windlord.stanford.edu',
86 undef, 'news:yld72axzc8.fsf@windlord.stanford.edu',
fe61459e 87 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ],
88
89 [ 'link|http://www.perl.org/',
90 'link', 'link', 'http://www.perl.org/', undef, 'url' ],
91
92 [ '0|http://www.perl.org/',
93 '0', '0', 'http://www.perl.org/', undef, 'url' ],
94
95 [ '0|Pod::Parser',
96 '0', '0', 'Pod::Parser', undef, 'pod' ],
b616daaf 97);
98
99BEGIN {
100 chdir 't' if -d 't';
101 unshift (@INC, '../blib/lib');
102 $| = 1;
b616daaf 103}
104
fe61459e 105use strict;
b616daaf 106
fe61459e 107use Test::More tests => 28;
108BEGIN { use_ok ('Pod::ParseLink') }
b616daaf 109
110# Used for reporting test failures.
111my @names = qw(text inferred name section type);
112
b616daaf 113for (@TESTS) {
114 my @expected = @$_;
115 my $link = shift @expected;
116 my @results = parselink ($link);
fe61459e 117 my $pretty = $link;
118 $pretty =~ s/\n/\\n/g;
119 is_deeply (\@results, \@expected, $pretty);
b616daaf 120}