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