#!/usr/bin/perl -w #$Id: 02links.t,v 1.6 2005/07/15 10:27:08 simonf Exp $ use strict; use lib qw(./lib ../lib); use Test; use Pod::Xhtml; use Getopt::Std; getopts('tTs', \my %opt); if ($opt{t} || $opt{T}) { require Log::Trace; import Log::Trace print => {Deep => $opt{T}}; } if (-d 't') { chdir( 't' ); } 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 $/; }; close OUT; TRACE("Double encoding output ($pod_output):\n", $output); ok(index($output, canned_links()) > -1); unlink $pod_output unless $opt{'s'}; sub canned_links { return <Test 1

http://www.bbc.co.uk/opensource/test?ARG=VAL&ARG2=VAL2

Test 2

Escaping Args & Values

Test 3

whatisan&doinghere

Test 4

"AUTHOR & ACKNOWLEDGEMENTS" in Pod::Xhtml

LINKS } # Log::Trace stubs sub TRACE {} sub DUMP {} __DATA__ =head1 DOUBLE ENCODING TEST Test 1 LARG2=VAL2> Test 2 L Values|http://www.bbc.co.uk/opensource/test?ARG=VALEARG2=VAL2> Test 3 Ldoinghere> Test 4 L ACKNOWLEDGEMENTS">