14 # First we create a file
15 open(F, ">file-$$") or die;
16 binmode F; # for DOSISH platforms, because test 3 copies to stdout
20 copy "file-$$", "copy-$$";
22 open(F, "copy-$$") or die;
26 print "not " if -s "file-$$" != -s "copy-$$";
29 print "not " unless $foo eq "ok 3\n";
32 copy "copy-$$", \*STDOUT;
33 unlink "copy-$$" or die "unlink: $!";
37 open(R, "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
38 print "not " unless $foo eq "ok 3\n";
40 unlink "copy-$$" or die "unlink: $!";
43 close(F) or die "close: $!";
44 open(R, "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
45 print "not " unless $foo eq "ok 3\n";
47 unlink "copy-$$" or die "unlink: $!";
50 $fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
53 $fh->close or die "close: $!";
54 open(R, "copy-$$") or die; $foo = <R>; close(R);
55 print "# foo=`$foo'\nnot " unless $foo eq "ok 3\n";
57 unlink "copy-$$" or die "unlink: $!";
59 my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
63 open(R, "copy-$$") or die; $foo = <R>; close(R);
64 print "not " unless $foo eq "ok 3\n";
66 unlink "file-$$" or die "unlink: $!";
68 print "# moved missing file.\nnot " if move("file-$$", "copy-$$");
69 print "# target disappeared.\nnot " if not -e "copy-$$";
72 move "copy-$$", "file-$$" or print "# move did not succeed.\n";
73 print "# not moved: $!\nnot " unless -e "file-$$" and not -e "copy-$$";
74 open(R, "file-$$") or die; $foo = <R>; close(R);
75 print "# foo=`$foo'\nnot " unless $foo eq "ok 3\n";
78 copy "file-$$", "lib";
79 open(R, "lib/file-$$") or die; $foo = <R>; close(R);
80 print "not " unless $foo eq "ok 3\n";
82 unlink "lib/file-$$" or die "unlink: $!";
84 move "file-$$", "lib";
85 open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
86 print "not " unless $foo eq "ok 3\n" and not -e "file-$$";;
88 unlink "lib/file-$$" or die "unlink: $!";