File: 010-resolvelink.t

package info (click to toggle)
libhtml-rewriteattributes-perl 0.05-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 216 kB
  • sloc: perl: 2,139; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# these tests are taken from HTML::ResolveLink, written by miyagawa
use strict;
use Test::More tests => 3;
use HTML::RewriteAttributes::Links;

my $base = "http://www.example.com/base/";
my $resolver = "HTML::RewriteAttributes::Links";

my $html = $resolver->rewrite(<<'HTML', $base);
<a href="/foo">foo</a><img src="/bar.gif" alt="foo &amp; bar" /> foobar
<a href="mailto:foobar@example.com">hey &amp;</a>
<a href="foo.html" onclick="foobar()">bar</a><br />
<a href="http://www.example.net/">bar</a>
<!-- hello -->
HTML

is $html, <<'HTML';
<a href="http://www.example.com/foo">foo</a><img src="http://www.example.com/bar.gif" alt="foo &amp; bar" /> foobar
<a href="mailto:foobar@example.com">hey &amp;</a>
<a href="http://www.example.com/base/foo.html" onclick="foobar()">bar</a><br />
<a href="http://www.example.net/">bar</a>
<!-- hello -->
HTML

$html = $resolver->rewrite(<<'HTML', $base);
<base href="http://www.google.com/">
<a href="baz">foo</a>
<base href="http://www.example.com/">
<a href="baz">foo</a>
HTML

is $html, <<'HTML', '<base>';
<base href="http://www.google.com/">
<a href="http://www.google.com/baz">foo</a>
<base href="http://www.example.com/">
<a href="http://www.example.com/baz">foo</a>
HTML
    ;

$html = $resolver->rewrite(<<'HTML', $base);
<a href="baz">&amp;</a>
&quot;foo&quot;
HTML

is $html, <<'HTML', 'HTML entities';
<a href="http://www.example.com/base/baz">&amp;</a>
&quot;foo&quot;
HTML
    ;