Debian lenny version packages
[pkg-perl] / deb-src / libcompress-raw-zlib-perl / libcompress-raw-zlib-perl-2.012 / t / 18lvalue.t
1 BEGIN {
2     if ($ENV{PERL_CORE}) {
3         chdir 't' if -d 't';
4         @INC = ("../lib", "lib/compress");
5     }
6 }
7
8 use lib qw(t t/compress);
9 use strict;
10 use warnings;
11 use bytes;
12
13 use Test::More ;
14 use CompTestUtils;
15
16 BEGIN 
17
18     plan(skip_all => "lvalue sub tests need Perl ??")
19         if $] < 5.006 ; 
20
21     # use Test::NoWarnings, if available
22     my $extra = 0 ;
23     $extra = 1
24         if eval { require Test::NoWarnings ;  import Test::NoWarnings; 1 };
25
26     plan tests => 10 + $extra ;
27
28     use_ok('Compress::Raw::Zlib', 2) ;
29 }
30  
31
32
33 my $hello = <<EOM ;
34 hello world
35 this is a test
36 EOM
37
38 my $len   = length $hello ;
39
40 # Check zlib_version and ZLIB_VERSION are the same.
41 is Compress::Raw::Zlib::zlib_version, ZLIB_VERSION, 
42     "ZLIB_VERSION matches Compress::Raw::Zlib::zlib_version" ;
43
44
45 {
46     title 'deflate/inflate with lvalue sub';
47
48     my $hello = "I am a HAL 9000 computer" ;
49     my $data = $hello ;
50
51     my($X, $Z);
52     sub getData : lvalue { $data }
53     sub getX    : lvalue { $X }
54     sub getZ    : lvalue { $Z }
55
56     ok my $x = new Compress::Raw::Zlib::Deflate ( -AppendOutput => 1 );
57
58     cmp_ok $x->deflate(getData, getX), '==',  Z_OK ;
59
60     cmp_ok $x->flush(getX), '==', Z_OK ;
61      
62     my $append = "Appended" ;
63     $X .= $append ;
64      
65     ok my $k = new Compress::Raw::Zlib::Inflate ( -AppendOutput => 1 ) ;
66      
67     cmp_ok $k->inflate(getX, getZ), '==', Z_STREAM_END ; ;
68      
69     ok $hello eq $Z ;
70     is $X, $append;
71     
72 }
73
74