1#!./perl
2use FileCache maxopen=>2;
3use Test;
4use vars qw(@files);
5BEGIN {
6    @files = qw(foo bar baz quux);
7    chdir 't' if -d 't';
8
9    #For tests within the perl distribution
10    @INC = '../lib' if -d '../lib';
11    END;
12    plan tests=>5;
13}
14END{
15  1 while unlink @files;
16}
17
18{# Test 2: that we actually adhere to maxopen
19  for my $path ( @files ){
20    cacheout $path;
21    print $path "$path 1\n";
22  }
23
24  my @cat;
25  for my $path ( @files ){
26    ok(fileno($path) || $path =~ /^(?:foo|bar)$/);
27    next unless fileno($path);
28    print $path "$path 2\n";
29    close($path);
30    open($path, $path);
31    <$path>;
32    push @cat, <$path>;
33    close($path);
34  }
35  ok( grep(/^(?:baz|quux) 2$/, @cat) == 2 );
36}
37