Skip Menu |

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

Report information
The Basics
Id: 42502
Status: resolved
Priority: 0/
Queue: Test-Weaken

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

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: suggest hook to initiate destroy
Date: Mon, 19 Jan 2009 07:58:51 +1100
To: bug-Test-Weaken [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
With perl-gtk2 windows, ie. top-level app windows, it's necessary to call $w->destroy, otherwise the object lives forever. (Gtk "helps" you by not demanding you keep a ref to a toplevel.) It'd be nice if Test::Weaken::poof had a hook of some kind so after it digs around in created object(s) that you get a chance to perform extra actions to ensure destruction. Maybe along the lines of poof (sub { return Gtk2::Window->new('toplevel') }, destroy => sub { $_[0]->destroy }); with the destroy func just receiving whatever the creator returns (so you could destroy on multiple objects, if you construct an array of objects, or whatnot). I think HTML::Tree has a similar explicit destructor thing, as $tree->delete.
Interesting. I'm thinking this one over. One issue is potential interaction between Test::Weaken and the custom destructor for an object to be tested.
Could you create a simple test case? I think that'd be three routines: a constructor that creates a circular reference; a destructor that correctly breaks the cycle; and a buggy destructor, which fails to break the cycle. This last perhaps could be as simple as a a no-op. I ask you to do them, because then I'll be sure I've actually fixed the bug that *YOU* have in mind, not just my idea of what you were thinking. If I understood you correctly, the test functions should not be hard to create. Just the functions themselves is all I need, I'll add the wrappering needed to turn them into proper tests for CPAN. Please don't use Gtk2 or any other non-core module -- I'll want them to work on as many of the cpantesters machines as possible. If I don't hear from you in a bit, I'll go ahead and create my test based on my best understanding of the issue.
Subject: Re: [rt.cpan.org #42502] suggest hook to initiate destroy
Date: Tue, 20 Jan 2009 08:42:33 +1100
To: bug-Test-Weaken [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
"Jeffrey Kegler via RT" <bug-Test-Weaken@rt.cpan.org> writes: Show quoted text
> > Could you create a simple test case?
Two little samples below, the first like gtk top-levels, the second a more basic circular ref. The first poof in each is what I'd been doing including a destroy in the constructor. The second is how I thought a destroy option to poof might look. Free free to give it a different name or style. It could be convenient to accept just a method name instead of a whole sub for the simplest case of a single object needing a single no-args method call to destruct ... except maybe such a case is too simple to arise often enough to want helping :-) Show quoted text
> a buggy destructor, which fails to break > the cycle. This last perhaps could be as simple as a a no-op.
Yes, in both cases it'd be the absense of a destroy which would be wrong. The "print"s of the second of each show the unfreed 1 or 3 refs in absense of a destroy option scheme.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Subject: Developer's release 1.001_000 has fix
I've created a developer's release with (I hope) your fix. It's 1.001_000. Try it out and let me know. I made the destructor simply a second coderef argument to poof(). The interface is still only two arguments, one optional, and they have a simple, natural relationship -- one's a constructor, the other is a destructor. It's still really too simple an interface to justify using a hash. You can check out how the new interface works from the two new test files based on your test cases: faux_gtk.t and circular.t. I've also updated the documentation. I'll leave this bug open for a few days to get your reaction.
Subject: Better developer's release: Test-Weaken-1.001_004
By accident, I did not include the test scripts in the previous developer's release. Test::Weaken developer's release 1.001_004 fixes that. In addition, it has many code fixes and is now perlcritic clean. This is a release candidate and if all goes well, will become Test::Weaken release 1.002000. Please test the new hook using this latest developer's release, 1.001_004. thanks. jeffrey kegler
Subject: Feature added in 1.002000
This feature has been added as of 1.002000, which I've just released. I will close this bug.
Feature added as of 1.002000.