12 printf "1..%d\n", $tests * scalar(@pass);
16 for my $pass (@pass) {
20 my $loopconst = $pass*$tests;
22 # First we create a file
23 open(F, ">file-$$") or die;
24 binmode F; # for DOSISH platforms, because test 3 copies to stdout
25 printf F "ok %d\n", 3 + $loopconst;
28 copy "file-$$", "copy-$$";
30 open(F, "copy-$$") or die;
34 print "not " if -s "file-$$" != -s "copy-$$";
35 printf "ok %d\n", 1 + $loopconst;
37 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
38 printf "ok %d\n", 2+$loopconst;
40 binmode STDOUT unless $^O eq 'VMS'; # Copy::copy works in binary mode
41 copy "copy-$$", \*STDOUT;
42 unlink "copy-$$" or die "unlink: $!";
46 open(R, "copy-$$") or die "open copy-$$: $!"; $foo = <R>; close(R);
47 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
48 printf "ok %d\n", 4+$loopconst;
49 unlink "copy-$$" or die "unlink: $!";
52 close(F) or die "close: $!";
53 open(R, "copy-$$") or die; $foo = <R>; close(R) or die "close: $!";
54 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
55 printf "ok %d\n", 5+$loopconst;
56 unlink "copy-$$" or die "unlink: $!";
59 $fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
62 $fh->close or die "close: $!";
63 open(R, "copy-$$") or die; $foo = <R>; close(R);
64 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
65 printf "ok %d\n", 6+$loopconst;
66 unlink "copy-$$" or die "unlink: $!";
68 my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
72 open(R, "copy-$$") or die; $foo = <R>; close(R);
73 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
74 printf "ok %d\n", 7+$loopconst;
75 unlink "file-$$" or die "unlink: $!";
77 print "# moved missing file.\nnot " if move("file-$$", "copy-$$");
78 print "# target disappeared.\nnot " if not -e "copy-$$";
79 printf "ok %d\n", 8+$loopconst;
81 move "copy-$$", "file-$$" or print "# move did not succeed.\n";
82 print "# not moved: $!\nnot " unless -e "file-$$" and not -e "copy-$$";
83 open(R, "file-$$") or die; $foo = <R>; close(R);
84 print "# foo=`$foo'\nnot " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
85 printf "ok %d\n", 9+$loopconst;
87 copy "file-$$", "lib";
88 open(R, "lib/file-$$") or die; $foo = <R>; close(R);
89 print "not " unless $foo eq sprintf "ok %d\n", 3+$loopconst;
90 printf "ok %d\n", 10+$loopconst;
91 unlink "lib/file-$$" or die "unlink: $!";
93 move "file-$$", "lib";
94 open(R, "lib/file-$$") or die "open lib/file-$$: $!"; $foo = <R>; close(R);
95 print "not " unless $foo eq sprintf("ok %d\n", 3+$loopconst)
96 and not -e "file-$$";;
97 printf "ok %d\n", 11+$loopconst;
98 unlink "lib/file-$$" or die "unlink: $!";
100 # warn sprintf "INC->".$INC{"File/Copy.pm"};
101 delete $INC{"File/Copy.pm"};
107 1 while unlink "file-$$";
108 1 while unlink "lib/file-$$";