Updated perl minimum version to 5.004. Replaced three-argument open with
[archive-zip.git] / t / 05_tree.t
blob7511074e96bcae2631944afaaa5de82063873919
1 #!/usr/bin/perl
3 use strict;
5 use strict;
6 BEGIN {
7 $| = 1;
8 $^W = 1;
10 use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
11 use FileHandle;
12 use File::Spec;
14 use Test::More tests =>6;
15 BEGIN {
16 unshift @INC, "t/";
17 require( File::Spec->catfile('t', 'common.pl') )
18 or die "Can't load t/common.pl";
21 use constant FILENAME => File::Spec->catfile(TESTDIR, 'testing.txt');
23 my $zip;
24 my @memberNames;
26 sub makeZip
28 my ($src, $dest, $pred) = @_;
29 $zip = Archive::Zip->new();
30 $zip->addTree($src, $dest, $pred);
31 @memberNames = $zip->memberNames();
34 sub makeZipAndLookFor
36 my ($src, $dest, $pred, $lookFor) = @_;
37 makeZip($src, $dest, $pred);
38 ok( @memberNames );
39 ok( (grep { $_ eq $lookFor } @memberNames) == 1 )
40 or print STDERR "Can't find $lookFor in (" . join(",", @memberNames) . ")\n";
43 my ($testFileVolume, $testFileDirs, $testFileName) = File::Spec->splitpath($0);
45 makeZipAndLookFor('.', '', sub { print "file $_\n"; -f && /\.t$/ }, 't/02_main.t' );
46 makeZipAndLookFor('.', 'e/', sub { -f && /\.t$/ }, 'e/t/02_main.t');
47 makeZipAndLookFor('./t', '', sub { -f && /\.t$/ }, '02_main.t' );