Commit | Line | Data |
16816334 |
1 | BEGIN { |
d695c1a1 |
2 | if ($ENV{PERL_CORE}) { |
16816334 |
3 | chdir 't' if -d 't'; |
0ecadccd |
4 | @INC = ("../lib", "lib"); |
16816334 |
5 | } |
6 | } |
642e522c |
7 | |
8 | use lib 't'; |
9 | use strict; |
10 | use warnings; |
11 | use bytes; |
12 | |
13 | use Test::More ; |
14 | use ZlibTestUtils; |
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::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::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 | |