6 use Test::More tests => 12;
10 use_ok('MooseX::Storage');
15 This test demonstrates two things:
17 - cycles will not work in the default engine
18 - you can use a special metaclass to tell
19 MooseX::Storage to skip an attribute
31 has 'cycle' => (is => 'rw', isa => 'Circular');
35 my $circular = Circular->new;
36 isa_ok($circular, 'Circular');
38 $circular->cycle($circular);
42 } qr/^Basic Engine does not support cycles/,
43 '... cannot collapse a cycle with the basic engine';
47 my $packed_circular = { __CLASS__ => 'Circular' };
48 $packed_circular->{cycle} = $packed_circular;
51 Circular->unpack($packed_circular);
52 } qr/^Basic Engine does not support cycles/,
53 '... cannot expand a cycle with the basic engine';
64 has 'node' => (is => 'rw');
73 metaclass => 'DoNotSerialize',
79 my ($self, $child) = @_;
80 $child->parent($self);
81 push @{$self->children} => $child;
86 my $t = Tree->new(node => 100);
96 '... got the right packed version');
98 my $t2 = Tree->new(node => 200);
103 is_deeply($t->children, [ $t2 ], '... got the right children in $t');
105 is($t2->parent, $t, '... created the cycle correctly');
106 isa_ok($t2->parent, 'Tree');
121 '... got the right packed version (with parent attribute skipped in child)');
130 '... got the right packed version (with parent attribute skipped)');