Commit | Line | Data |
a917fb06 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | |
5 | use lib qw(t/lib); |
6 | |
7 | BEGIN { |
a109c954 |
8 | require DBIx::Class; |
9 | plan skip_all => 'Test needs: ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_cycle') |
10 | unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_cycle') ); |
a917fb06 |
11 | } |
12 | |
13 | use DBICTest; |
14 | use DBICTest::Schema; |
551e711a |
15 | use Scalar::Util (); |
a917fb06 |
16 | |
17 | import Test::Memory::Cycle; |
18 | |
551e711a |
19 | my $weak; |
a917fb06 |
20 | |
551e711a |
21 | { |
22 | my $s = $weak->{schema} = DBICTest->init_schema; |
23 | memory_cycle_ok($s, 'No cycles in schema'); |
24 | |
25 | my $rs = $weak->{resultset} = $s->resultset ('Artist'); |
26 | memory_cycle_ok($rs, 'No cycles in resultset'); |
27 | |
28 | my $rsrc = $weak->{resultsource} = $rs->result_source; |
29 | memory_cycle_ok($rsrc, 'No cycles in resultsource'); |
30 | |
31 | my $row = $weak->{row} = $rs->first; |
32 | memory_cycle_ok($row, 'No cycles in row'); |
33 | |
34 | Scalar::Util::weaken ($_) for values %$weak; |
35 | memory_cycle_ok($weak, 'No cycles in weak object collection'); |
36 | } |
37 | |
38 | for (keys %$weak) { |
39 | ok (! $weak->{$_}, "No $_ leaks"); |
40 | } |
41 | |
42 | done_testing; |