Add test preambles to Compress::Zlib.
[p5sagit/p5-mst-13.2.git] / ext / Compress / Zlib / t / 18lvalue.t
CommitLineData
16816334 1BEGIN {
2 if ($ENV{PERL_CORE} {
3 chdir 't' if -d 't';
4 @INC = '../lib';
5 }
6}
642e522c 7
8use lib 't';
9use strict;
10use warnings;
11use bytes;
12
13use Test::More ;
14use ZlibTestUtils;
15
16BEGIN
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::Zlib', 2) ;
29}
30
31
32
33my $hello = <<EOM ;
34hello world
35this is a test
36EOM
37
38my $len = length $hello ;
39
40# Check zlib_version and ZLIB_VERSION are the same.
41is Compress::Zlib::zlib_version, ZLIB_VERSION,
42 "ZLIB_VERSION matches Compress::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::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::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