1#!/usr/bin/env perl 2use strict; 3use warnings; 4 5BEGIN { 6 unless ($ENV{RELEASE_TESTING}) { 7 require Test::More; 8 Test::More::plan(skip_all => 'these tests are for release candidate testing'); 9 } 10} 11 12#--------------------------------------------------------------------- 13 14 15use Test::More; 16eval "use Test::Weaken"; 17plan skip_all => "Test::Weaken required for testing leaks" if $@; 18 19use Math::Prime::Util qw/prime_iterator primes factor moebius/; 20use Math::Prime::Util::PrimeIterator; 21 22my $leaks; 23 24$leaks = Test::Weaken::leaks( 25 { constructor => sub { 26 my $it = prime_iterator(100); 27 return \$it; 28 } 29 }); 30ok(!$leaks, "Prime iterator doesn't leak"); 31 32$leaks = Test::Weaken::leaks( 33 { constructor => sub { 34 my $it = Math::Prime::Util::PrimeIterator->new(100); 35 return \$it; 36 } 37 }); 38ok(!$leaks, "Prime iterator object doesn't leak"); 39 40$leaks = Test::Weaken::leaks( 41 { constructor => sub { 42 my $it = prime_iterator("1000000000000000000000000"); 43 my $p = $it->(); 44 return \$it; 45 } 46 }); 47ok(!$leaks, "Prime iterator object doesn't leak"); 48 49$leaks = Test::Weaken::leaks( 50 sub { 51 my $primes = primes(66000); 52 return $primes 53 }); 54ok(!$leaks, "primes array doesn't leak"); 55 56$leaks = Test::Weaken::leaks( 57 sub { 58 return [factor(2938424874)]; 59 }); 60ok(!$leaks, "factor array doesn't leak"); 61 62$leaks = Test::Weaken::leaks( 63 sub { 64 return [moebius(500,1000)]; 65 }); 66ok(!$leaks, "moebius range doesn't leak"); 67 68done_testing(); 69