<?xml version="1.0" encoding="windows-1252"?>
<node id="480824" title="Re^2: When test-driven development just won't do" created="2005-08-04 09:53:09" updated="2005-08-12 10:32:45">
<type id="11">
note</type>
<author id="268515">
xdg</author>
<data>
<field name="doctext">
&lt;p&gt;For random number generation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Option (a) parse [mod://Statistics::ChiSquare]&lt;/li&gt;
&lt;li&gt;Option (b) use [mod://Statistics::Distributions] (if you know how to do a chi-squared test)&lt;/li&gt;
&lt;li&gt;Option (c) stick with established PRNG routines (e.g. [mod://Math::Random::MT] and [mod://Math::Random::MT::Auto]) because unless you really know what you're doing, your results are going to be biased and if you know what you're doing, then you probably already know how to check your results&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For garbage collection, if you really want to do this, why not install your own &lt;code&gt;UNIVERSAL::DESTROY&lt;/code&gt; subroutine during testing:
&lt;code&gt;
use strict;
use warnings;

package Foo;

sub new { return bless {} }

package main;

use Test::More tests =&gt; 3;

my %destroyed;
$destroyed{Foo} = 0;

{
    no strict 'refs';
    *{"UNIVERSAL::DESTROY"} = sub { $destroyed{ref(shift)}++ };
}

my $obj1 = Foo-&gt;new;
my $obj2 = Foo-&gt;new;

is( $destroyed{Foo}, 0, "Nothing destroyed yet" );
$obj1 = undef;
is( $destroyed{Foo}, 1, "Destroyed 1" );
$obj2 = undef;
is( $destroyed{Foo}, 2, "Destroyed 2" );

__END__

1..3
ok 1 - Nothing destroyed yet
ok 2 - Destroyed 1
ok 3 - Destroyed 2
&lt;/code&gt;

&lt;div class="pmsig"&gt;&lt;div class="pmsig-268515"&gt;
&lt;p&gt;-xdg&lt;/p&gt;
&lt;p&gt;&lt;small&gt;&lt;i&gt;Code written by xdg and posted on PerlMonks is &lt;a href="http://creativecommons.org/licenses/publicdomain"&gt;public domain&lt;/a&gt;. It is provided &lt;b&gt;as is&lt;/b&gt; with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.&lt;/i&gt;&lt;/small&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
480680</field>
<field name="parent_node">
480791</field>
</data>
</node>
