Test::DiagRef - Detailed diagnostics for your reference tracking tests
version 1.132080
use Test::More tests => 1; use Test::DiagRef; use Scalar::Util 'weaken'; my $obj = MyClass->new(); weaken(my $ref = $obj); # Delete $obj undef $obj; # Uncomment this line to show a leak is($ref, undef, 'no leak') or diag_ref $ref;
Test::DiagRef is an utility module for writing tests for memory leaks. It will not check for memory leaks himself (that's your job as a test author), but at least provide an advanced report if your test found one.
The only sub exported is diag_ref($ref). It is expected to be used where Test::More's diag is used: to provide advanced diagnostics when a test failed. The given $ref will be explored.
diag_ref($ref)
diag
$ref
Devel::FindRef is the module that provides the detailed report. But it is loaded on demand, only if $ref is defined. This saves ressources if your test did not detect a leak.
The runtime dependency on Devel::FindRef is optional. If it is not installed when the test found a leak, diag_ref will just report a message suggesting to install it. This ensures that using Test::DiagRef has low dependancy impact on your own CPAN (or DarkPAN) distribution. You can safely use Test::DiagRef for development, and still keep it in the test suite of the distribution.
Devel::FindRef
diag_ref
Test::DiagRef
The diag sub in Test::More.
Olivier Mengué, mailto:dolmen@cpan.org
Copyright © 2013 Olivier Mengué.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
To install Test::DiagRef, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::DiagRef
CPAN shell
perl -MCPAN -e shell install Test::DiagRef
For more information on module installation, please visit the detailed CPAN module installation guide.