Add ARM files
[dh-make-perl] / dev / arm / liburi-perl / liburi-perl-1.35.dfsg.1 / t / file.t
1 #!perl -w
2
3 use URI::file;
4
5 @tests =  (
6 [ "file",          "unix",       "win32",         "mac" ],
7 #----------------  ------------  ---------------  --------------
8 [ "file://localhost/foo/bar",
9                    "!/foo/bar",  "!\\foo\\bar",   "!foo:bar", ],
10 [ "file:///foo/bar",
11                    "/foo/bar",   "\\foo\\bar",    "!foo:bar", ],
12 [ "file:/foo/bar", "!/foo/bar",  "!\\foo\\bar",   "foo:bar", ],
13 [ "foo/bar",       "foo/bar",    "foo\\bar",      ":foo:bar",],
14 [ "file://foo/bar","!//foo/bar", "!\\\\foo\\bar", "!foo:bar"],
15 [ "file://a:/",    "!//a:/",     "!A:\\",         undef],
16 [ "file:///A:/",   "/A:/",       "A:\\",          undef],
17 [ "file:///",      "/",          "\\",            undef],
18 [ ".",             ".",          ".",             ":"],
19 [ "..",            "..",         "..",            "::"],
20 [ "%2E",           "!.",         "!.",           ":."],
21 [ "../%2E%2E",     "!../..",     "!..\\..",      "::.."],
22 );
23
24 @os = @{shift @tests};
25 shift @os;  # file
26
27 my $num = @tests;
28 print "1..$num\n";
29
30 $testno = 1;
31
32 for $t (@tests) {
33    my @t = @$t;
34    my $file = shift @t;
35    my $err;
36
37    my $u = URI->new($file, "file");
38    my $i = 0;
39    for $os (@os) {
40        my $f = $u->file($os);
41        my $expect = $t[$i];
42        $f = "<undef>" unless defined $f;
43        $expect = "<undef>" unless defined $expect;
44        my $loose;
45        $loose++ if $expect =~ s/^!//;
46        if ($expect ne $f) {
47            print "URI->new('$file', 'file')->file('$os') ne $expect, but $f\n";
48            $err++;
49        }
50        if (defined($t[$i]) && !$loose) {
51            $u2 = URI::file->new($t[$i], $os);
52            unless ($u2->as_string eq $file) {
53               print "URI::file->new('$t[$i]', '$os') ne $file, but $u2\n";
54               $err++;
55            }
56        }
57        $i++;
58    }
59    print "not " if $err;
60    print "ok $testno\n";
61    $testno++;
62 }