12 printf "1..%d\n", $tests * scalar(@pass);
16 for my $pass (@pass) {
18 my $loopconst = $pass*$tests;
20 # First we create a file
21 open(F, ">file-$$") or die;
22 binmode F; # for DOSISH platforms, because test 3 copies to stdout
23 printf F "ok %d\n", 3 + $loopconst;
26 copy "file-$$", "copy-$$";
28 open(F, "copy-$$") or die;
32 print "not " if -s "file-$$" != -s "copy-$$";
33 printf "ok %d\n", 1 + $loopconst;
35 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
36 printf "ok %d\n", 2+$loopconst;
38 binmode STDOUT unless $^O eq 'VMS'; # Copy::copy works in binary mode
39 copy "copy-$$", \*STDOUT;
40 unlink "copy-$$" or die "unlink: $!";
44 open(R, "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
45 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
46 printf "ok %d\n", 4+$loopconst;
47 unlink "copy-$$" or die "unlink: $!";
50 close(F) or die "close: $!";
51 open(R, "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
52 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
53 printf "ok %d\n", 5+$loopconst;
54 unlink "copy-$$" or die "unlink: $!";
57 $fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
60 $fh->close or die "close: $!";
61 open(R, "copy-$$") or die; $foo = <R>; close(R);
62 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
63 printf "ok %d\n", 6+$loopconst;
64 unlink "copy-$$" or die "unlink: $!";
66 my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
70 open(R, "copy-$$") or die; $foo = <R>; close(R);
71 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
72 printf "ok %d\n", 7+$loopconst;
73 unlink "file-$$" or die "unlink: $!";
75 print "# moved missing file.\nnot " if move("file-$$", "copy-$$");
76 print "# target disappeared.\nnot " if not -e "copy-$$";
77 printf "ok %d\n", 8+$loopconst;
79 move "copy-$$", "file-$$" or print "# move did not succeed.\n";
80 print "# not moved: $!\nnot " unless -e "file-$$" and not -e "copy-$$";
81 open(R, "file-$$") or die; $foo = <R>; close(R);
82 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
83 printf "ok %d\n", 9+$loopconst;
85 copy "file-$$", "lib";
86 open(R, "lib/file-$$") or die; $foo = <R>; close(R);
87 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
88 printf "ok %d\n", 10+$loopconst;
89 unlink "lib/file-$$" or die "unlink: $!";
91 move "file-$$", "lib";
92 open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
93 print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst)
94 and not -e "file-$$";;
95 printf "ok %d\n", 11+$loopconst;
96 unlink "lib/file-$$" or die "unlink: $!";
101 1 while unlink "file-$$";
102 1 while unlink "lib/file-$$";