#!/usr/local/bin/perl -w
#$Id: 02links.t,v 1.9 2006/08/29 12:48:11 andreww Exp $
use strict;
use lib qw(./lib ../lib);
use Test;
use Pod::Xhtml;
use Getopt::Std;
use File::Basename;
getopts('tTs', \my %opt);
if ($opt{t} || $opt{T}) {
require Log::Trace;
import Log::Trace print => {Deep => $opt{T}};
}
chdir ( dirname ( $0 ) );
require Test_LinkParser;
plan tests => 16;
my $pod_links = new Test_LinkParser();
my $parser = new Pod::Xhtml( LinkParser => $pod_links );
# Links to manpages
ok($parser->seqL('Pod::Xhtml') eq 'Pod::Xhtml');
ok($parser->seqL('XHTML Podlator|Pod::Xhtml') eq 'XHTML Podlator (Pod::Xhtml)');
ok($parser->seqL('crontab(5)') eq 'crontab(5)');
# Links to section in other manpages
ok($parser->seqL('Pod::Xhtml/"SEE ALSO"') eq 'SEE ALSO in Pod::Xhtml');
ok($parser->seqL('alt text|Pod::Xhtml/"SEE ALSO"') eq 'alt text (SEE ALSO in Pod::Xhtml)');
ok($parser->seqL('Pod::Xhtml/SYNOPSIS') eq 'SYNOPSIS in Pod::Xhtml');
ok($parser->seqL('alt text|Pod::Xhtml/SYNOPSIS') eq 'alt text (SYNOPSIS in Pod::Xhtml)');
# Links to sections in this manpage
# Since 1.41, these are fully resolved at the end of the POD parse
ok($parser->seqL('/"User Guide"') eq 'User Guide');
ok($parser->seqL('alt text|/"User Guide"') eq 'alt text');
ok($parser->seqL('/Notes') eq 'Notes');
ok($parser->seqL('alt text|/Notes') eq 'alt text');
ok($parser->seqL('"Installation Guide"') eq 'Installation Guide');
ok($parser->seqL('alt text|"Installation Guide"') eq 'alt text');
# Links to web pages
ok($parser->seqL('http://bbc.co.uk/') eq 'http://bbc.co.uk/');
ok($parser->seqL('http://bbc.co.uk/#top') eq 'http://bbc.co.uk/#top');
my $pod_output = 'links.out';
open(OUT, '+>'.$pod_output) or die("Can't open $pod_output: $!");
$parser->parse_from_filehandle(\*DATA, \*OUT);
seek OUT, 0, 0;
my $output = do {local $/;
http://www.bbc.co.uk/opensource/test?ARG=VAL&ARG2=VAL2
Test 2
Test 3
Test 4
"AUTHOR & ACKNOWLEDGEMENTS" in Pod::Xhtml
LINKS } # Log::Trace stubs sub TRACE {} sub DUMP {} __DATA__ =head1 DOUBLE ENCODING TEST Test 1 L