10 use FileCache maxopen=>2;
11 my @files = qw(foo bar baz quux);
13 {# Test 1: that we can open files
14 for my $path ( @files ){
16 print $path "$path 1\n";
18 print "not " unless scalar map({ -f } @files) == 4;
23 {# Test 2: that we actually adhere to maxopen
25 for my $path ( @files ){
26 print $path "$path 2\n";
33 print "not " if (grep {/foo|bar/} @cat) && ! (grep {/baz|quux/} @cat);
37 {# Test 3: that we open for append on second viewing
39 for my $path ( @files ){
41 print $path "$path 3\n";
43 for my $path ( @files ){
45 push @cat, do{ local $/; <$path>};
48 print "not " unless scalar map({ /3$/ } @cat) == 4;
53 {# Test 4: that 2 arg format works
58 print "not " unless <foo> eq "foo 2\n";
63 {# Test 5: that close is overridden properly
64 cacheout local $_ = "Foo_Bar";
65 print $_ "Hello World\n";
70 print "not " unless <$_> eq "$_\n";
76 {# Test close override
79 cacheout local $_ = "Foo_Bar";
80 print $_ "Hello World\n";
85 print "not " unless <$_> eq "$_\n";
91 1 while unlink @files, "Foo_Bar";