Re: DEMOLISH and bad call to new()
[email protected] (Ernesto)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
Hi Stevan, there is a little misunderstanding: The test file http://dienstleistung-kultur.de/moose/02_demolish_required.t.txt is actually a combination of three test files or runs (against Moose::Object 0.11): First run: The test 'Baz plain' will fail: # Uncomment only one block per test run: # #=pod check_em ( 'Baz' ); # 'Baz plain' will fail, aka NO error check_em ( 'Qee' ); # ok check_em ( 'Foo' ); # ok #=cut =pod check_em ( 'Qee' ); # 'Qee plain' will fail, aka NO error check_em ( 'Baz' ); # ok check_em ( 'Foo' ); # ok =cut =pod check_em ( 'Foo' ); # ok check_em ( 'Baz' ); # ok ! check_em ( 'Qee' ); # ok =cut Second run (after changing the file): The test 'Qee plain' will fail: =pod check_em ( 'Baz' ); # 'Baz plain' will fail, aka NO error check_em ( 'Qee' ); # ok check_em ( 'Foo' ); # ok =cut #=pod check_em ( 'Qee' ); # 'Qee plain' will fail, aka NO error check_em ( 'Baz' ); # ok check_em ( 'Foo' ); # ok #=cut =pod check_em ( 'Foo' ); # ok check_em ( 'Baz' ); # ok ! check_em ( 'Qee' ); # ok =cut At activating only the last block all tests are successfull. Running all three blocks at once makes no sense, because the bug shines on only at the very first call. Moreover the tests show, that the order of the objects resp. of the calls to new() is important, because since Foo has no DEMOLISH defined, all three tests run ok. Ok, the patch has healed the bug, but you can't have the cake and eat it too: Maybe it might be worth to notice, that now errors inside DEMOLISH can't be tested because of the localization of $@ - but wait: perltoot says "So you are guaranteed that an object /eventually/ gets properly destroyed, except in the unique case of a program that never exits." But these consideration might become too esoteric ;-) Please have a look at http://dienstleistung-kultur.de/moose/03_demolish_esoteric.t.txt and run the tests against Moose::Object 0.11 and 0.12. I think, returning the original error from new() (e.g. type error) and not an error from DEMOLISH is the right way, so please have a look at http://dienstleistung-kultur.de/moose/04_demolish_wanted_behaviour.t.txt The devil is always in the detail ;-) Ernesto