/
roy-test.t
38 lines (34 loc) · 965 Bytes
/
roy-test.t
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
print "1..102\n";
if (-d "t") {
chdir("t") || die "Can't chdir 't': $!";
# fix all relative library locations
foreach (@INC) {
$_ = "../$_" unless m,^/,;
}
}
use URI;
$no = 1;
for $i (1..5) {
my $file = "roytest$i.html";
open(FILE, $file) || die "Can't open $file: $!";
print "# $file\n";
$base = undef;
while (<FILE>) {
if (/^<BASE href="([^"]+)">/) {
$base = URI->new($1);
} elsif (/^<a href="([^"]*)">.*<\/a>\s*=\s*(\S+)/) {
die "Missing base at line $." unless $base;
$link = $1;
$exp = $2;
$exp = $base if $exp =~ /current/; # special case test 22
$abs = URI->new($link)->abs($base);
unless ($abs eq $exp) {
print "$file:$.: Expected: $exp\n";
print qq( abs("$link","$base") ==> "$abs"\n);
print "not ";
}
print "ok $no\n";
$no++;
}
}
}