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