Fix [perl #66970] Incorrect coderef in MODIFY_CODE_ATTRIBUTES
[p5sagit/p5-mst-13.2.git] / ext / Archive-Tar / t / 05_iter.t
CommitLineData
642eb381 1BEGIN {
2 if( $ENV{PERL_CORE} ) {
3 chdir '../lib/Archive/Tar' if -d '../lib/Archive/Tar';
4 }
5 use lib '../../..';
6}
7
8BEGIN { chdir 't' if -d 't' }
9
10use Test::More 'no_plan';
11use strict;
12use lib '../lib';
13
14my $Class = 'Archive::Tar';
15my $FClass = 'Archive::Tar::File';
16my $File = 'src/long/bar.tar';
17my @Expect = (
18 qr|^c$|,
19 qr|^d$|,
20 qr|^directory/$|,
21 qr|^directory/really.*name/$|,
22 qr|^directory/.*/myfile$|,
23);
24
25use_ok( $Class );
26
27### crazy ref to special case 'all'
28for my $index ( \0, 0 .. $#Expect ) {
29
30 my %opts = ();
31 my @expect = ();
32
33 ### do a full test vs individual filters
34 if( not ref $index ) {
35 my $regex = $Expect[$index];
36 $opts{'filter'} = $regex;
37 @expect = ($regex);
38 } else {
39 @expect = @Expect;
40 }
41
42 my $next = $Class->iter( $File, 0, \%opts );
43
44 my $pp_opts = join " => ", %opts;
45 ok( $next, "Iterator created from $File ($pp_opts)" );
46 isa_ok( $next, "CODE", " Iterator" );
47
48 my @names;
49 while( my $f = $next->() ) {
50 ok( $f, " File object retrieved" );
51 isa_ok( $f, $FClass, " Object" );
52
53 push @names, $f->name;
54 }
55
56 is( scalar(@names), scalar(@expect),
57 " Found correct number of files" );
58
59 my $i = 0;
60 for my $name ( @names ) {
61 ok( 1, " Inspecting '$name' " );
62 like($name, $expect[$i]," Matches $Expect[$i]" );
63 $i++;
64 }
65}