rewrite home page redirect
[dh-make-perl] / dev / arm / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / linkextor-rel.t
1 use Test::More tests => 4;
2
3 require HTML::LinkExtor;
4
5 $HTML = <<HTML;
6 <head>
7 <base href="http://www.sn.no/">
8 </head>
9 <body background="http://www.sn.no/sn.gif">
10
11 This is <A HREF="link.html">link</a> and an <img SRC="img.jpg"
12 lowsrc="img.gif" alt="Image">.
13 HTML
14
15
16 # Try the callback interface
17 $links = "";
18 $p = HTML::LinkExtor->new(
19   sub {
20       my($tag, %links) = @_;
21       #diag "$tag @{[%links]}";
22       $links .= "$tag @{[%links]}\n";
23   });
24
25 $p->parse($HTML); $p->eof;
26
27 ok($links =~ m|^base href http://www\.sn\.no/$|m);
28 ok($links =~ m|^body background http://www\.sn\.no/sn\.gif$|m);
29 ok($links =~ m|^a href link\.html$|m);
30
31 # Used to be problems when using the links method on a document with
32 # no links it it.  This is a test to prove that it works.
33 $p = new HTML::LinkExtor;
34 $p->parse("this is a document with no links"); $p->eof;
35 @a = $p->links;
36 is(@a, 0);