Commits

Toby Inkster committed 34f5f08

fieldhashes bugfix

  • Participants
  • Parent commits 37f8e67

Comments (0)

Files changed (3)

File lib/Object/Stash.pm

 
 BEGIN {
 	$Object::Stash::AUTHORITY = 'cpan:TOBYINK';
-	$Object::Stash::VERSION   = '0.001';
+	$Object::Stash::VERSION   = '0.002';
 }
 
 use Carp qw/croak/;
 use Scalar::Util qw/blessed/;
 use Sub::Name qw/subname/;
 
-fieldhashes \my (%known_stashes);
+my %known_stashes;
+my %Stashes;
+BEGIN {
+	fieldhashes \%known_stashes, \%Stashes;
+}
 
 sub import
 {
 	return;
 }
 
-{
-	fieldhashes \my (%Stashes);
-	
+{	
 	sub _stash
 	{
 		my ($stashname, $self, @args) = @_;

File meta/changes.ttl

 	:file-release   <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/Object-Stash-0.001.tar.gz> ;
 	rdfs:label      "Initial release" .
 
+dist:project :release dist:v_0-002 .
+dist:v_0-002
+	a               :Version ;
+	dc:issued       "2011-11-30"^^xsd:date ;
+	:revision       "0.002"^^xsd:string ;
+	:file-release   <http://backpan.cpan.org/authors/id/T/TO/TOBYINK/Object-Stash-0.002.tar.gz> ;
+	dcs:changeset [
+		dcs:versus dist:v_0-001 ;
+		dcs:item   [ rdfs:label "Test case for stash destruction." ] ;
+		dcs:item   [ rdfs:label "Pretty important fieldhashes compile-time-versus-run-time fix." ; a dcs:Bugfix ] ;
+		] .
+

File t/03destruction.t

+use Test::More;
+
+{
+	package Local::Vocal;
+	$Local::Vocal::Flag = 0;
+	sub new {
+		my ($class, $n) = @_;
+		#Test::More::diag("Creating $n");
+		bless \$n, $class;
+	}
+	sub DESTROY {
+		my $n = ${$_[0]};
+		#Test::More::diag("Destroying $n");		
+		Test::More::ok($Local::Vocal::Flag, "Destroying $n");
+	}
+}
+
+{
+	package Local::WithStash;
+	use Object::Stash;
+	sub new { bless [], $_[0]; }	
+}
+
+package main;
+use Test::More;
+
+# We're going to start the testing, so set the flag to 1, which will
+# mean that each object destruction passes a test.
+$Local::Vocal::Flag = 1;
+
+plan tests => (my $count = 10);
+foreach my $i (1..$count)
+{
+	my $obj = Local::WithStash->new;
+	$obj->stash( vocal => Local::Vocal->new($i) );
+	# Allow object to go out of scope.
+}
+
+# By now, our original 10 objects should all be completely destroyed.
+# Set the flag to 0, which will cause them to fail a test when destroyed.
+$Local::Vocal::Flag = 0;
+