4 |
|
|
5 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
6 |
|
|
7 |
use Test::More tests => 227; |
use Test::More tests => 254; |
8 |
use File::Slurp; |
use File::Slurp; |
9 |
use IO::File; |
use IO::File; |
10 |
|
|
21 |
ok( open(my $d, '<', "$to/.debug"), 'open debug' ); |
ok( open(my $d, '<', "$to/.debug"), 'open debug' ); |
22 |
local $/; |
local $/; |
23 |
my $dump = <$d>; |
my $dump = <$d>; |
24 |
diag "DEBUG: $msg\n$dump\n"; |
diag "DEBUG: $msg\n$dump\n" if $debug; |
25 |
ok( close($d), 'close debug' ); |
ok( close($d), 'close debug' ); |
26 |
} |
} |
27 |
|
|
97 |
|
|
98 |
} |
} |
99 |
|
|
|
diag "multiple read-write"; |
|
100 |
|
|
101 |
ok( my $fh1 = IO::File->new("> $to/m"), 'open 1' ); |
sub multiple_rw { |
102 |
$fh1->autoflush; |
|
103 |
ok( print($fh1 "1.1\n"), 'print 1.1' ); |
diag "multiple read-write"; |
104 |
ok( my $fh2 = IO::File->new(">> $to/m"), 'open 2' ); |
ok( my $fh1 = IO::File->new("> $to/m"), 'open 1' ); |
105 |
$fh2->autoflush; |
$fh1->autoflush; |
106 |
ok( print($fh2 "2.1\n"), 'print 2.1' ); |
ok( print($fh1 "1.1\n"), 'print 1.1' ); |
107 |
cmp_ok( read_file("$to/m"), 'eq', "1.1\n2.1\n", 'mixed' ); |
ok( my $fh2 = IO::File->new(">> $to/m"), 'open 2' ); |
108 |
ok( print($fh1 "1.2\n"), 'print 1.2' ); |
$fh2->autoflush; |
109 |
cmp_ok( read_file("$to/m"), 'eq', "1.1\n1.2\n", 'just 1' ); |
ok( print($fh2 "2.1\n"), 'print 2.1' ); |
110 |
|
cmp_ok( read_file("$to/m"), 'eq', "1.1\n2.1\n", 'mixed' ); |
111 |
|
ok( print($fh1 "1.2\n"), 'print 1.2' ); |
112 |
|
cmp_ok( read_file("$to/m"), 'eq', "1.1\n1.2\n", 'just 1' ); |
113 |
|
dump_debug 'own twice'; |
114 |
|
ok( print($fh1 "x" x 65535), 'print 1 64k' ); |
115 |
|
ok( close($fh1), 'close 1' ); |
116 |
|
dump_debug 'own once'; |
117 |
|
ok( close($fh2), 'close 2' ); |
118 |
|
dump_debug 'closed'; |
119 |
|
|
120 |
|
} |
121 |
|
|
122 |
|
multiple_rw; |
123 |
|
multiple_rw; |
124 |
|
|
125 |
|
|