Debian Codegraph @

ext/FileCache/t/03append.t

raw
1 #!./perl
2
3 use FileCache maxopen => 2;
4 our @files;
5 BEGIN { @files = map { "append_$_" } qw(foo bar baz quux Foo_Bar) }
6 END { 1 while unlink @files }
7
8 use Test::More tests => 2;
9
10 {# Test 3: that we open for append on second viewing
11 my @cat;
12 for my $path ( @files ){
13 cacheout $path;
14 print $path "$path 3\n";
15 }
16 for my $path ( @files ){
17 cacheout $path;
18 print $path "$path 33\n";
19 }
20 for my $path ( @files ){
21 open($path, '<', $path);
22 push @cat, do{ local $/; <$path>};
23 close($path);
24 }
25
26 ok(scalar(grep/\b3$/m, @cat) == scalar(@files));
27
28 @cat = ();
29 for my $path ( @files ){
30 cacheout $path;
31 print $path "$path 333\n";
32 }
33 for my $path ( @files ){
34 open($path, '<', $path);
35 push @cat, do{ local $/; <$path>};
36 close($path);
37 }
38 ok(scalar(grep /\b33$/m, @cat) == scalar(@files));
39 }