Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: When test-driven development just won't do

by xdg (Monsignor)
on Aug 04, 2005 at 13:53 UTC ( #480824=note: print w/replies, xml ) Need Help??


in reply to Re: When test-driven development just won't do
in thread When test-driven development just won't do

For random number generation:

For garbage collection, if you really want to do this, why not install your own UNIVERSAL::DESTROY subroutine during testing:

use strict; use warnings; package Foo; sub new { return bless {} } package main; use Test::More tests => 3; my %destroyed; $destroyed{Foo} = 0; { no strict 'refs'; *{"UNIVERSAL::DESTROY"} = sub { $destroyed{ref(shift)}++ }; } my $obj1 = Foo->new; my $obj2 = Foo->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

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://480824]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2016-12-11 01:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (168 votes). Check out past polls.