xref: /openbsd-src/gnu/usr.bin/perl/ext/FileCache/t/03append.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1b39c5158Smillert#!./perl
2b39c5158Smillert
3b39c5158Smillertuse FileCache maxopen => 2;
45759b3d2Safresh1our @files;
5*f2a19305Safresh1BEGIN { @files = map { "append_$_" } qw(foo bar baz quux Foo_Bar) }
6b39c5158SmillertEND   { 1 while unlink @files }
7b39c5158Smillert
8b39c5158Smillertuse Test::More tests => 2;
9b39c5158Smillert
10b39c5158Smillert{# Test 3: that we open for append on second viewing
11b39c5158Smillert     my @cat;
12b39c5158Smillert     for my $path ( @files ){
13b39c5158Smillert	 cacheout $path;
14b39c5158Smillert	 print $path "$path 3\n";
15b39c5158Smillert     }
16b39c5158Smillert     for my $path ( @files ){
17b39c5158Smillert	 cacheout $path;
18b39c5158Smillert	 print $path "$path 33\n";
19b39c5158Smillert     }
20b39c5158Smillert     for my $path ( @files ){
21b39c5158Smillert	 open($path, '<', $path);
22b39c5158Smillert	 push @cat, do{ local $/; <$path>};
23b39c5158Smillert         close($path);
24b39c5158Smillert     }
25b39c5158Smillert
26b39c5158Smillert     ok(scalar(grep/\b3$/m, @cat) == scalar(@files));
27b39c5158Smillert
28b39c5158Smillert     @cat = ();
29b39c5158Smillert     for my $path ( @files ){
30b39c5158Smillert	 cacheout $path;
31b39c5158Smillert	 print $path "$path 333\n";
32b39c5158Smillert     }
33b39c5158Smillert     for my $path ( @files ){
34b39c5158Smillert	 open($path, '<', $path);
35b39c5158Smillert	 push @cat, do{ local $/; <$path>};
36b39c5158Smillert         close($path);
37b39c5158Smillert     }
38b39c5158Smillert     ok(scalar(grep /\b33$/m, @cat) == scalar(@files));
39b39c5158Smillert}
40