summaryrefslogtreecommitdiff
path: root/t/lib/filecopy.t
blob: 8c64be1c98ff5c9763ece062632a5236d87a23c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!./perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

print "1..5\n";

$| = 1;

use File::Copy;

# First we create a file
open(F, ">file-$$") or die;
print F "ok 3\n";
close F;

copy "file-$$", "copy-$$";

open(F, "copy-$$") or die;
$foo = <F>;
close(F);

print "not " if -s "file-$$" != -s "copy-$$";
print "ok 1\n";

print "not " unless $foo eq "ok 3\n";
print "ok 2\n";

copy "copy-$$", \*STDOUT;

unlink "file-$$";

print "not " if move("file-$$", "copy-$$") or not -e "copy-$$";
print "ok 4\n";

move "copy-$$", "file-$$";

print "not " unless -e "file-$$" and not -e "copy-$$";
print "ok 5\n";

unlink "file-$$";