File: 50_leaktrace.t

package info (click to toggle)
libdata-messagepack-perl 1.02-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,060 kB
  • sloc: ansic: 5,697; perl: 1,123; makefile: 10
file content (62 lines) | stat: -rw-r--r-- 1,082 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!perl -w
use strict;
use Test::Requires { 'Test::LeakTrace' => 0.13 };
use Test::More;
use Data::MessagePack;
BEGIN {
    if($INC{'Data/MessagePack/PP.pm'}) {
        plan skip_all => 'disabled in PP';
     }
}

my $simple_data  = "xyz";
my $complex_data = {
    a => 'foo',
    b => 42,
    c => undef,
    d => [qw(bar baz)],
    e => 3.14,
};

note 'pack';

no_leaks_ok {
    my $s = Data::MessagePack->pack($complex_data);
};

no_leaks_ok {
    eval { Data::MessagePack->pack([\*STDIN]) };
    note $@;
    $@ or warn "# it must die";
};

note 'unpack';

my $s = Data::MessagePack->pack($simple_data);
my $c = Data::MessagePack->pack($complex_data);

no_leaks_ok {
    my $data = Data::MessagePack->unpack($s);
};

no_leaks_ok {
    my $data = Data::MessagePack->unpack($c);
};

no_leaks_ok {
    my $broken = $s;
    chop $broken;
    eval { Data::MessagePack->unpack($broken) };
    note $@;
    $@ or warn "# it must die";
};

note 'stream';

no_leaks_ok {
    my $up = Data::MessagePack::Unpacker->new();
    $up->execute($c);
    my $data = $up->data();
};

done_testing;