cycle tests and a weaken call
Matt S Trout [Sat, 22 Apr 2006 16:29:28 +0000 (16:29 +0000)]
Changes
lib/DBIx/Class/Schema.pm
t/52cycle.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 0d1e740..8efad83 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for DBIx::Class
 
+0.06003
+        - added memory cycle tests and a long-needed weaken call
+
 0.06002 2006-04-20 00:42:41
         - fix set_from_related to accept undef
         - fix to Dumper-induced hash iteration bug
index 56e002b..9105477 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use Carp::Clan qw/^DBIx::Class/;
+use Scalar::Util qw/weaken/;
 
 use base qw/DBIx::Class/;
 
@@ -94,6 +95,7 @@ sub register_source {
   $reg{$moniker} = $source;
   $self->source_registrations(\%reg);
   $source->schema($self);
+  weaken($source->{schema}) if ref($self);
   if ($source->result_class) {
     my %map = %{$self->class_mappings};
     $map{$source->result_class} = $moniker;
diff --git a/t/52cycle.t b/t/52cycle.t
new file mode 100644 (file)
index 0000000..0c1e330
--- /dev/null
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+use Test::More;
+
+use lib qw(t/lib);
+
+BEGIN {
+  eval { require Test::Memory::Cycle };
+  if ($@) {
+    plan skip_all => "leak test needs Test::Memory::Cycle";
+  } else {
+    plan tests => 1;
+  }
+}
+
+use DBICTest;
+use DBICTest::Schema;
+
+import Test::Memory::Cycle;
+
+my $s = DBICTest::Schema->clone;
+
+memory_cycle_ok($s, 'No cycles in schema');