use strict;
use warnings;
use Test::More;
use Config::Any;
eval { require Test::LeakTrace; };
if( $@ ) {
plan skip_all => 'Test::LeakTrace required for this test';
}
else {
plan tests => 2;
}
Test::LeakTrace::no_leaks_ok( sub { bless {}, 'MyConfig'; } );
Test::LeakTrace::no_leaks_ok( sub { MyConfig->new; } );
package MyConfig;
use Config::Any;
sub new {
my $class = shift;
my $conf = Config::Any->load_files( {
files => [ qw( t/conf/conf.pl ) ],
use_ext => 1,
flatten_to_hash => 1
} );
return bless $conf, $class;
}
1;
__END__
t/leaks.t ..
1..2
ok 1 - leaks 0 == 0
not ok 2 - leaks 8 == 0
# Failed test 'leaks 8 == 0'
# at t/leaks.t line 17.
# got: 8
# expected: 0
# leaked SCALAR(0x953a1a8) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x953a1a4) at 0x953a1a8
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 156474536
# leaked SCALAR(0x93e7800) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x93e77fc) at 0x93e7800
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 156474216
# leaked SCALAR(0x93e74c0) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x93e74bc) at 0x93e74c0
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 156069040
# leaked SCALAR(0x93e74a0) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x93e749c) at 0x93e74a0
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 156452128
# leaked SCALAR(0x93e7420) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x93e741c) at 0x93e7420
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 156453408
# leaked SCALAR(0x93e7380) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x93e737c) at 0x93e7380
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 155419272
# leaked SCALAR(0x9553b90) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x9553b8c) at 0x9553b90
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 156206264
# leaked SCALAR(0x9553a20) from /usr/local/lib/perl/5.10.0/XSLoader.pm line 94.
# 93: push(@DynaLoader::dl_shared_objects, $file); # record files loaded
# 94: return &$xs(@_);
# 95:
# SV = IV(0x9553a1c) at 0x9553a20
# REFCNT = 1
# FLAGS = (IOK,pIOK)
# IV = 155084944
# Looks like you failed 1 test of 2.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
Test Summary Report
-------------------
t/leaks.t (Wstat: 256 Tests: 2 Failed: 1)
Failed test: 2
Non-zero exit status: 1
Files=1, Tests=2, 0 wallclock secs ( 0.01 usr 0.01 sys + 0.07 cusr 0.01 csys = 0.10 CPU)
Result: FAIL