xref: /openbsd/gnu/usr.bin/perl/dist/Storable/t/leaks.t (revision a6445c1d)
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