1#!./perl
2
3use Test::More;
4use Storable ();
5BEGIN {
6eval "use Test::LeakTrace";
7plan 'skip_all' => 'Test::LeakTrace required for this tests' if $@;
8}
9plan 'tests' => 1;
10
11{
12    my $c = My::Simple->new;
13    my $d;
14    my $freezed = Storable::freeze($c);
15    no_leaks_ok
16    {
17        $d = Storable::thaw($freezed);
18        undef $d;
19    };
20
21    package My::Simple;
22    sub new {
23        my ($class, $arg) = @_;
24        bless {t=>$arg}, $class;
25    }
26    sub STORABLE_freeze {
27        return "abcderfgh";
28    }
29    sub STORABLE_attach {
30        my ($class, $c, $serialized) = @_;
31        return $class->new($serialized);
32    }
33}
34
35{ # [cpan #97316]
36  package TestClass;
37
38  sub new {
39    my $class = shift;
40    return bless({}, $class);
41  }
42  sub STORABLE_freeze {
43    die;
44  }
45
46  package main;
47  my $obj = TestClass->new;
48  eval { freeze($obj); };
49}
50