File: z_leaktrace.t

package info (click to toggle)
libcpanel-json-xs-perl 3.0225-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,660 kB
  • ctags: 799
  • sloc: perl: 892; makefile: 8
file content (24 lines) | stat: -rw-r--r-- 695 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!perl -w
# note that does not catch the leaking XS context cxt->sv_json #19
# even valgrind does not catch it

use strict;
use constant HAS_LEAKTRACE => eval{ require Test::LeakTrace };
use Test::More HAS_LEAKTRACE ? (tests => 1) : (skip_all => 'require Test::LeakTrace');
use Test::LeakTrace;

use Cpanel::JSON::XS;

leaks_cmp_ok{
  my $js = Cpanel::JSON::XS->new->convert_blessed->allow_tags->allow_nonref;
  $js->decode('"\ud801\udc02' . "\x{10204}\"");
  $js->decode('"\"\n\\\\\r\t\f\b"');
  $js->ascii->utf8->encode(chr 0x8000);

  sub Temp::TO_JSON { 7 }
  $js->encode ( bless { k => 1 }, Temp:: );

  sub Temp1::FREEZE { (3,1,2) }
  $js->encode ( bless { k => 1 }, Temp1:: );

} '<', 1;