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   15470 use strict;
  1         2  
  1         209  
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 26 my $thing = shift;
14 22 50       52 $thing = shift if ref($thing) eq 'MyOtherFreezer';
15              
16 22 50       37 if (ref($thing) eq 'SCALAR') {
    0          
17 22         95 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 28 my $thing = shift;
27 22 50       51 $thing = shift if ref($thing) eq 'MyOtherFreezer';
28              
29 22         99 my ($type, @stuff) = split /\0/, reverse($thing);
30 22 50       79 if ($type eq 'SCALAR') {
    0          
31 22         34 my $scalar = $stuff[0];
32 22         78 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;