1use constant HAS_LEAKTRACE => eval{ require Test::LeakTrace }; 2use Test::More HAS_LEAKTRACE ? (tests => 1) : (skip_all => 'require Test::LeakTrace'); 3use Test::LeakTrace; 4 5#check for memory leaks 6 7use pQuery; 8 9no_leaks_ok{ 10 my $t = -d 't' ? 't' : 'test'; 11 my $pq = pQuery("$t/document2.html"); 12 13 $pq->find('td')->each(sub { 14 my $i = shift; 15 my $elem = $_; 16 }); 17} 'memory leak with traversal'; 18 19 20