[inseparable changes from patch from perl5.003_13 to perl5.003_14]
[p5sagit/p5-mst-13.2.git] / t / lib / filecopy.t
CommitLineData
1a3850a5 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
71be2cbc 8print "1..11\n";
1a3850a5 9
10$| = 1;
11
12use File::Copy;
13
14# First we create a file
15open(F, ">file-$$") or die;
16print F "ok 3\n";
17close F;
18
19copy "file-$$", "copy-$$";
20
21open(F, "copy-$$") or die;
22$foo = <F>;
23close(F);
24
25print "not " if -s "file-$$" != -s "copy-$$";
26print "ok 1\n";
27
28print "not " unless $foo eq "ok 3\n";
29print "ok 2\n";
30
31copy "copy-$$", \*STDOUT;
71be2cbc 32unlink "copy-$$";
1a3850a5 33
71be2cbc 34open(F,"file-$$");
35copy(*F, "copy-$$");
36open(R, "copy-$$") or die; $foo = <R>; close(R);
37print "not " unless $foo eq "ok 3\n";
38print "ok 4\n";
39unlink "copy-$$";
40open(F,"file-$$");
41copy(\*F, "copy-$$");
42open(R, "copy-$$") or die; $foo = <R>; close(R);
43print "not " unless $foo eq "ok 3\n";
44print "ok 5\n";
45unlink "copy-$$";
46
47require IO::File;
48$fh = IO::File->new(">copy-$$") or die "Cannot open copy-$$:$!";
49copy("file-$$",$fh);
50$fh->close;
51open(R, "copy-$$") or die; $foo = <R>; close(R);
52print "not " unless $foo eq "ok 3\n";
53print "ok 6\n";
54unlink "copy-$$";
55require FileHandle;
56my $fh = FileHandle->new(">copy-$$") or die "Cannot open copy-$$:$!";
57copy("file-$$",$fh);
58$fh->close;
59open(R, "copy-$$") or die; $foo = <R>; close(R);
60print "not " unless $foo eq "ok 3\n";
61print "ok 7\n";
1a3850a5 62unlink "file-$$";
441496b2 63
64print "not " if move("file-$$", "copy-$$") or not -e "copy-$$";
71be2cbc 65print "ok 8\n";
441496b2 66
67move "copy-$$", "file-$$";
441496b2 68print "not " unless -e "file-$$" and not -e "copy-$$";
71be2cbc 69open(R, "file-$$") or die; $foo = <R>; close(R);
70print "not " unless $foo eq "ok 3\n";
71print "ok 9\n";
72
73copy "file-$$", "lib";
74open(R, "lib/file-$$") or die; $foo = <R>; close(R);
75print "not " unless $foo eq "ok 3\n";
76print "ok 10\n";
77unlink "lib/file-$$";
78
79move "file-$$", "lib";
80open(R, "lib/file-$$") or die; $foo = <R>; close(R);
81print "not " unless $foo eq "ok 3\n" and not -e "file-$$";;
82print "ok 11\n";
83unlink "lib/file-$$";
441496b2 84