From: Paul Brannan Date: 2003-12-14T06:16:43+09:00 Subject: Re: How to unit test finalizers? On Fri, Dec 12, 2003 at 11:57:04PM +0900, Simon Strandgaard wrote: > On Fri, 12 Dec 2003 23:43:43 +0900, Paul Brannan wrote: > > While it is your responsibility to call the finalizers, it is our > > responsibility to make sure that there are no references to the object > > hanging around keeping the object from being finalized. I don't know of > > any good, portable way to unit test that, though. > > Wouldn't it be possible to spawn a child process, where a instance outputs > something when it gets finalized. > Then the parent process could do a assert_equal(count_open, count_close) This only guarantees that the finalizer was registered properly with the garbage collector. It's still possible to have a bug that keeps the object from being garbage collected until Ruby exits. Paul