diff options
Diffstat (limited to 't/linkextor-rel.t')
-rw-r--r-- | t/linkextor-rel.t | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/linkextor-rel.t b/t/linkextor-rel.t new file mode 100644 index 0000000..1190a96 --- /dev/null +++ b/t/linkextor-rel.t @@ -0,0 +1,36 @@ +use Test::More tests => 4; + +require HTML::LinkExtor; + +$HTML = <<HTML; +<head> +<base href="http://www.sn.no/"> +</head> +<body background="http://www.sn.no/sn.gif"> + +This is <A HREF="link.html">link</a> and an <img SRC="img.jpg" +lowsrc="img.gif" alt="Image">. +HTML + + +# Try the callback interface +$links = ""; +$p = HTML::LinkExtor->new( + sub { + my($tag, %links) = @_; + #diag "$tag @{[%links]}"; + $links .= "$tag @{[%links]}\n"; + }); + +$p->parse($HTML); $p->eof; + +ok($links =~ m|^base href http://www\.sn\.no/$|m); +ok($links =~ m|^body background http://www\.sn\.no/sn\.gif$|m); +ok($links =~ m|^a href link\.html$|m); + +# Used to be problems when using the links method on a document with +# no links it it. This is a test to prove that it works. +$p = new HTML::LinkExtor; +$p->parse("this is a document with no links"); $p->eof; +@a = $p->links; +is(@a, 0); |