From: Matt S Trout Date: Tue, 16 Jun 2009 21:26:56 +0000 (+0100) Subject: test now doesn't run but is closer to the right structure X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FMutually-Assured-Destruction.git;a=commitdiff_plain;h=6e01520b1b67b6dbe048b986abc23d43e92e08a6 test now doesn't run but is closer to the right structure --- diff --git a/t/01simple.t b/t/01simple.t index 34b800b..3af11f4 100644 --- a/t/01simple.t +++ b/t/01simple.t @@ -6,10 +6,47 @@ use Scalar::Util qw(weaken); my %real; my %weak; +my @names = qw(one two); + +my %next_name; + +foreach my $idx (-1 .. $#names-1) { + $next_name{$names[$idx+1]} = $names[$idx]; +} + +my %last_name = reverse %next_name; + +# construct objects + +foreach my $name (@names) { + weaken($weak{$name} = $real{$name} = bless({}, 'Foo')); +} + +# setup forward and back pointers + +foreach my $name (@names) { + $real{$name}->{forward} = $real{$next_name{$name}}; + weaken($real{$next_name{$name}->{back} = $real{$name}); +} + +# weaken last forward pointer + +weaken($real{$names[-1]}->{forward}); + +# to test: undef each one in order +# undef all but one +# undef all and verify destruction + + + @weak{qw(one two)} = @real{qw(one two)} = ({}, {}); weaken($_) for values %weak; +$real{one}->{two} = $real{two}; + +$real{two}->{one} = $real{one}; + delete @real{keys %real}; cmp_ok(