#!./perl
BEGIN {
chdir 't' if -d 't';
}
$| = 1;
my @pass = (0,1);
use Config;
my $loopconst = $pass*$tests;
# First we create a file
binmode F; # for DOSISH platforms, because test 3 copies to stdout
close F;
$foo = <F>;
print "not " if -s "file-$$" != -s "copy-$$";
printf "ok %d\n", 6+$loopconst;
unlink "copy-$$" or die "unlink: $!";
require FileHandle;
my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
binmode $fh or die;
copy("file-$$",$fh);
$fh->close;
open(R, "copy-$$") or die; $foo = <R>; close(R);
print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
printf "ok %d\n", 7+$loopconst;
unlink "file-$$" or die "unlink: $!";
print "# moved missing file.\nnot " if move("file-$$", "copy-$$");
print "# target disappeared.\nnot " if not -e "copy-$$";
printf "ok %d\n", 8+$loopconst;
move "copy-$$", "file-$$" or print "# move did not succeed.\n";
print "# not moved: $!\nnot " unless -e "file-$$" and not -e "copy-$$";
open(R, "file-$$") or die; $foo = <R>; close(R);
my $test_i;
if ($^O eq 'MacOS') {
unless (-e 'lib:') { # make sure there's no volume called 'lib'
undef $@;
print "# Died: $@";
}
$test_i = 15;
} else {
$test_i = 12;
}
print F "dummy content\n";
close F;
} else {
}
print F "dummy content\n";
close F;
} else {
}
} else {
}
}
END {
} else {
}
}