#!/usr/bin/perl -w # # parselink.t -- Tests for Pod::ParseLink. # # Copyright 2001, 2009 by Russ Allbery # # This program is free software; you may redistribute it and/or modify it # under the same terms as Perl itself. # The format of each entry in this array is the L<> text followed by the # five-element parse returned by parselink. our @TESTS = ( [ 'foo', undef, 'foo', 'foo', undef, 'pod' ], [ 'foo|bar', 'foo', 'foo', 'bar', undef, 'pod' ], [ 'foo/bar', undef, '"bar" in foo', 'foo', 'bar', 'pod' ], [ 'foo/"baz boo"', undef, '"baz boo" in foo', 'foo', 'baz boo', 'pod' ], [ '/bar', undef, '"bar"', undef, 'bar', 'pod' ], [ '/"baz boo"', undef, '"baz boo"', undef, 'baz boo', 'pod' ], [ '/baz boo', undef, '"baz boo"', undef, 'baz boo', 'pod' ], [ 'foo bar/baz boo', undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ], [ 'foo bar / baz boo', undef, '"baz boo" in foo bar', 'foo bar', 'baz boo', 'pod' ], [ "foo\nbar\nbaz\n/\nboo", undef, '"boo" in foo bar baz', 'foo bar baz', 'boo', 'pod' ], [ 'anchor|name/section', 'anchor', 'anchor', 'name', 'section', 'pod' ], [ '"boo var baz"', undef, '"boo var baz"', undef, 'boo var baz', 'pod' ], [ 'bar baz', undef, '"bar baz"', undef, 'bar baz', 'pod' ], [ '"boo bar baz / baz boo"', undef, '"boo bar baz / baz boo"', undef, 'boo bar baz / baz boo', 'pod' ], [ 'fooZ<>bar', undef, 'fooZ<>bar', 'fooZ<>bar', undef, 'pod' ], [ 'Testing I|foo/bar', 'Testing I', 'Testing I', 'foo', 'bar', 'pod' ], [ 'foo/I text', undef, '"I text" in foo', 'foo', 'I text', 'pod' ], [ 'fooEbarZ<>/Section C I markup', undef, '"Section C I markup" in fooEbarZ<>', 'fooEbarZ<>', 'Section C I markup', 'pod' ], [ 'Nested L|fooEbar', 'Nested L', 'Nested L', 'fooEbar', undef, 'pod' ], [ 'ls(1)', undef, 'ls(1)', 'ls(1)', undef, 'man' ], [ ' perlfunc(1)/open ', undef, '"open" in perlfunc(1)', 'perlfunc(1)', 'open', 'man' ], [ 'some manual page|perl(1)', 'some manual page', 'some manual page', 'perl(1)', undef, 'man' ], [ 'http://www.perl.org/', undef, 'http://www.perl.org/', 'http://www.perl.org/', undef, 'url' ], [ 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'news:yld72axzc8.fsf@windlord.stanford.edu', 'news:yld72axzc8.fsf@windlord.stanford.edu', undef, 'url' ], [ 'link|http://www.perl.org/', 'link', 'link', 'http://www.perl.org/', undef, 'url' ], [ '0|http://www.perl.org/', '0', '0', 'http://www.perl.org/', undef, 'url' ], [ '0|Pod::Parser', '0', '0', 'Pod::Parser', undef, 'pod' ], ); BEGIN { chdir 't' if -d 't'; unshift (@INC, '../blib/lib'); $| = 1; } use strict; use Test::More tests => 28; BEGIN { use_ok ('Pod::ParseLink') } # Used for reporting test failures. my @names = qw(text inferred name section type); for (@TESTS) { my @expected = @$_; my $link = shift @expected; my @results = parselink ($link); my $pretty = $link; $pretty =~ s/\n/\\n/g; is_deeply (\@results, \@expected, $pretty); }