This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / lib / FileCache / t / 03append.t
1 #!./perl
2 use FileCache maxopen=>2;
3 use vars qw(@files);
4 BEGIN {
5     @files = qw(foo bar baz quux Foo'Bar);
6     chdir 't' if -d 't';
7
8     #For tests within the perl distribution
9     @INC = '../lib' if -d '../lib';
10     END;
11 }
12 END{
13   unlink @files;
14 }
15
16 print "1..2\n";
17
18 {# Test 3: that we open for append on second viewing
19      my @cat;
20      for my $path ( @files ){
21          cacheout $path;
22          print $path "$path 3\n";
23      }
24      for my $path ( @files ){
25          cacheout $path;
26          print $path "$path 33\n";
27      }
28      for my $path ( @files ){
29          open($path, '<', $path);
30          push @cat, do{ local $/; <$path>};
31          close($path);
32      }
33      print 'not ' unless scalar grep(/\b3$/m, @cat) == scalar @files;
34      print "ok 1\n";
35      @cat = ();
36      for my $path ( @files ){
37          cacheout $path;
38          print $path "$path 333\n";
39      }
40      for my $path ( @files ){
41          open($path, '<', $path);
42          push @cat, do{ local $/; <$path>};
43          close($path);
44      }
45      print 'not ' unless scalar grep(/\b33$/m, @cat) == scalar @files;
46      print "ok 2\n";
47 }