6 push @INC, "::lib:$MacPerl::Architecture" if $^O eq 'MacOS';
12 my $tests = $^O eq 'MacOS' ? 15 : 12;
13 printf "1..%d\n", $tests * scalar(@pass);
17 for my $pass (@pass) {
19 my $loopconst = $pass*$tests;
21 # First we create a file
22 open(F, ">file-$$") or die;
23 binmode F; # for DOSISH platforms, because test 3 copies to stdout
24 printf F "ok %d\n", 3 + $loopconst;
27 copy "file-$$", "copy-$$";
29 open(F, "copy-$$") or die;
33 print "not " if -s "file-$$" != -s "copy-$$";
34 printf "ok %d\n", 1 + $loopconst;
36 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
37 printf "ok %d\n", 2+$loopconst;
39 binmode STDOUT unless $^O eq 'VMS'; # Copy::copy works in binary mode
40 copy "copy-$$", \*STDOUT;
41 unlink "copy-$$" or die "unlink: $!";
45 open(R, "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
46 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
47 printf "ok %d\n", 4+$loopconst;
48 unlink "copy-$$" or die "unlink: $!";
51 close(F) or die "close: $!";
52 open(R, "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
53 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
54 printf "ok %d\n", 5+$loopconst;
55 unlink "copy-$$" or die "unlink: $!";
58 $fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
61 $fh->close or die "close: $!";
62 open(R, "copy-$$") or die; $foo = <R>; close(R);
63 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
64 printf "ok %d\n", 6+$loopconst;
65 unlink "copy-$$" or die "unlink: $!";
67 my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
71 open(R, "copy-$$") or die; $foo = <R>; close(R);
72 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
73 printf "ok %d\n", 7+$loopconst;
74 unlink "file-$$" or die "unlink: $!";
76 print "# moved missing file.\nnot " if move("file-$$", "copy-$$");
77 print "# target disappeared.\nnot " if not -e "copy-$$";
78 printf "ok %d\n", 8+$loopconst;
80 move "copy-$$", "file-$$" or print "# move did not succeed.\n";
81 print "# not moved: $!\nnot " unless -e "file-$$" and not -e "copy-$$";
82 open(R, "file-$$") or die; $foo = <R>; close(R);
83 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
84 printf "ok %d\n", 9+$loopconst;
88 copy "file-$$", "lib";
89 open(R, ":lib:file-$$") or die; $foo = <R>; close(R);
90 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
91 printf "ok %d\n", 10+$loopconst;
92 unlink ":lib:file-$$" or die "unlink: $!";
94 copy "file-$$", ":lib";
95 open(R, ":lib:file-$$") or die; $foo = <R>; close(R);
96 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
97 printf "ok %d\n", 11+$loopconst;
98 unlink ":lib:file-$$" or die "unlink: $!";
100 copy "file-$$", ":lib:";
101 open(R, ":lib:file-$$") or die; $foo = <R>; close(R);
102 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
103 printf "ok %d\n", 12+$loopconst;
104 unlink ":lib:file-$$" or die "unlink: $!";
106 unless (-e 'lib:') { # make sure there's no volume called 'lib'
108 eval { (copy "file-$$", "lib:") || die "'lib:' is not a volume name"; };
110 print "not " unless ( $@ =~ m|'lib:' is not a volume name| );
112 printf "ok %d\n", 13+$loopconst;
114 move "file-$$", ":lib:";
115 open(R, ":lib:file-$$") or die "open :lib:file-$$: $!"; $foo = <R>; close(R);
116 print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst)
117 and not -e "file-$$";;
118 printf "ok %d\n", 14+$loopconst;
120 eval { copy("copy-$$", "copy-$$") };
121 printf "ok %d\n", 15+$loopconst
122 unless $@ =~ /are identical/ && -s "copy-$$";
124 unlink ":lib:file-$$" or die "unlink: $!";
128 copy "file-$$", "lib";
129 open(R, "lib/file-$$") or die; $foo = <R>; close(R);
130 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
131 printf "ok %d\n", 10+$loopconst;
132 unlink "lib/file-$$" or die "unlink: $!";
134 move "file-$$", "lib";
135 open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
136 print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst)
137 and not -e "file-$$";;
138 printf "ok %d\n", 11+$loopconst;
140 eval { copy("copy-$$", "copy-$$") };
141 printf "ok %d\n", 12+$loopconst
142 unless $@ =~ /are identical/ && -s "copy-$$";
144 unlink "lib/file-$$" or die "unlink: $!";
151 1 while unlink "file-$$";
152 if ($^O eq 'MacOS') {
153 1 while unlink ":lib:file-$$";
155 1 while unlink "lib/file-$$";