File Coverage

mylib/MyOtherFreezer.pm
Criterion Covered Total %
statement 13 19 68.4
branch 4 12 33.3
condition n/a
subroutine 3 4 75.0
pod 0 3 0.0
total 20 38 52.6


line stmt bran cond sub pod time code
1             # A sample external freezer for POE::Filter::Reference testing.
2              
3             package MyOtherFreezer;
4              
5 1     1   14939 use strict;
  1         1  
  1         260  
6              
7             sub new {
8 0     0 0 0 my $type = shift;
9 0         0 return bless [ ], $type;
10             }
11              
12             sub freeze {
13 22     22 0 19 my $thing = shift;
14 22 50       36 $thing = shift if ref($thing) eq 'MyOtherFreezer';
15              
16 22 50       27 if (ref($thing) eq 'SCALAR') {
    0          
17 22         69 return reverse(join "\0", ref($thing), $$thing);
18             }
19             elsif (ref($thing) eq 'Package') {
20 0         0 return reverse(join "\0", ref($thing), @$thing);
21             }
22 0         0 die "can't freeze things of type ", ref($thing);
23             }
24              
25             sub thaw {
26 22     22 0 25 my $thing = shift;
27 22 50       41 $thing = shift if ref($thing) eq 'MyOtherFreezer';
28              
29 22         72 my ($type, @stuff) = split /\0/, reverse($thing);
30 22 50       50 if ($type eq 'SCALAR') {
    0          
31 22         22 my $scalar = $stuff[0];
32 22         66 return \$scalar;
33             }
34             elsif ($type eq 'Package') {
35 0           return bless \@stuff, $type;
36             }
37 0           die "can't thaw things of type $type";
38             }
39              
40             1;