Skip Menu |

This queue is for tickets about the Test-Weaken CPAN distribution.

Report information
The Basics
Id: 48127
Status: stalled
Priority: 0/
Queue: Test-Weaken

People
Owner: KRYDE [...] cpan.org
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 3.001_000
Fixed in: (no value)



Subject: not tracking tied array/hash/scalar values
Date: Fri, 24 Jul 2009 06:39:08 +1000
To: bug-Test-Weaken [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
When Test::Weaken looks at a tied array or hash, I believe there's no actual scalars which are elements or values and therefore no underlying storage to track in that case. I think the way the current code takes proberefs like \($aref->[0]) ends up, on a tied array, with a ref to a new magical scalar thingie which does calls to FETCH and STORE. The little program below suggests you get a brand new magical thingie on every single ref, so there isn't even a shared one that might be checked against leaks, instead the taking of the proberef brings a new one into existance. The upshot would be that Test::Weaken could save some work on tied arrays, hashes, and probably tied scalars too, by not attempting to track the elements of those. It should still fetch the values and track (I think) and descend into them as usual, just that \($aref->[0]) doesn't refer to any actual storage in the case of a tie.
#!/usr/bin/perl use strict; use warnings; package MaiTai; sub TIEARRAY { return bless { abc => 123, def => 456 }, __PACKAGE__; } sub FETCHSIZE { return 1; } sub FETCH { return 999; } package main; my $aref; { my @array; tie @array, 'MaiTai'; $aref = \@array; } my @refs; foreach (1..5) { push @refs, \($aref->[0]); } foreach my $ref (@refs) { print "$ref\n"; } print "refs 0 and 1 are ", ($refs[0] == $refs[1] ? "equal" : "NOT equal"), "\n"; exit 0;
Stalled, because waiting in the "TO DO" queue.