1BEGIN {
2    if ($ENV{PERL_CORE}) {
3	chdir 't' if -d 't';
4	@INC = ("../lib", "lib/compress");
5    }
6}
7
8use lib qw(t t/compress);
9use strict;
10use warnings;
11use bytes;
12
13use Test::More ;
14use CompTestUtils;
15
16
17BEGIN {
18    # use Test::NoWarnings, if available
19    my $extra = 0 ;
20    $extra = 1
21        if eval { require Test::NoWarnings ;  import Test::NoWarnings; 1 };
22
23    plan tests => 390 + $extra ;
24}
25
26
27{
28    use Compress::Raw::Zlib ;
29
30    my %all;
31    for my $symbol (@Compress::Raw::Zlib::DEFLATE_CONSTANTS)
32    {
33        eval "defined Compress::Raw::Zlib::$symbol" ;
34        $all{$symbol} = ! $@ ;
35    }
36
37    my $pkg = 1;
38
39    for my $module ( qw( Adapter::Deflate RawDeflate Deflate Gzip Zip ))
40    {
41        ++ $pkg ;
42        eval <<EOM;
43            package P$pkg;
44            use Test::More ;
45            use CompTestUtils;
46
47            use IO::Compress::$module () ;
48
49            ::title "IO::Compress::$module - no import" ;
50EOM
51        is $@, "", "create package P$pkg";
52        for my $symbol (@Compress::Raw::Zlib::DEFLATE_CONSTANTS)
53        {
54            if ( $all{$symbol})
55            {
56                eval "package P$pkg; defined IO::Compress::${module}::$symbol ;";
57                is $@, "", "  has $symbol";
58            }
59            else
60            {
61                ok 1, "  $symbol not available";
62            }
63        }
64    }
65
66    for my $module ( qw( Adapter::Deflate RawDeflate Deflate Gzip Zip ))
67    {
68        for my $label (keys %Compress::Raw::Zlib::DEFLATE_CONSTANTS)
69        {
70            ++ $pkg ;
71
72            eval <<EOM;
73                package P$pkg;
74                use Test::More ;
75                use CompTestUtils;
76
77                use IO::Compress::$module qw(:$label) ;
78
79                ::title "IO::Compress::$module - import :$label" ;
80
81EOM
82            is $@, "", "create package P$pkg";
83
84            for my $symbol (@{ $Compress::Raw::Zlib::DEFLATE_CONSTANTS{$label} } )
85            {
86                if ( $all{$symbol})
87                {
88                    eval "package P$pkg; defined $symbol ;";
89                    is $@, "", "  has $symbol";
90                }
91                else
92                {
93                    ok 1, "  $symbol not available";
94                }
95            }
96        }
97    }
98
99}
100