From: Dave Rolsky Date: Thu, 24 Dec 2009 20:17:45 +0000 (-0600) Subject: Add a test that singletons are not destroyed (although this doesn't test the real... X-Git-Tag: 0.22~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a82b9823df87d8eb3bda661ea08254a534344dee;p=gitmo%2FMooseX-Singleton.git Add a test that singletons are not destroyed (although this doesn't test the real bug report, which involved POE) --- diff --git a/Makefile.PL b/Makefile.PL index b6df86c..934caa0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,6 +7,7 @@ all_from 'lib/MooseX/Singleton.pm'; requires 'Moose' => '0.82'; +build_requires 'Scalar::Util'; build_requires 'Test::More'; build_requires 'Test::Exception'; diff --git a/t/003-immutable.t b/t/003-immutable.t index 39e45bd..1385d07 100644 --- a/t/003-immutable.t +++ b/t/003-immutable.t @@ -1,6 +1,7 @@ use strict; use warnings; +use Scalar::Util qw( refaddr ); use Test::More; BEGIN { @@ -8,7 +9,7 @@ BEGIN { plan skip_all => 'These tests require Test::Warn'; } else { - plan tests => 17; + plan tests => 18; } } @@ -80,3 +81,14 @@ is($mst->distinct_keys, 0, "Package->clear works"); is($mst2->distinct_keys, 0, "Package->clear works"); is(MooseX::Singleton::Test->distinct_keys, 0, "Package->clear works"); +{ + my $addr; + + { + $addr = refaddr( MooseX::Singleton::Test->instance ); + } + + is( $addr, refaddr( MooseX::Singleton::Test->instance ), + 'singleton is not randomly destroyed' ); +} +