[Perlunit-users] assert_isa, assert_can: accept class names?
Status: Beta
Brought to you by:
mca1001
From: Matthew A. <mc...@us...> - 2005-10-22 18:16:10
|
I've just added to CVS Marek's patch from the RT bug at http://rt.cpan.org/NoAuth/Bug.html?id=4613 Changes will be visible at http://cvs.sourceforge.net/viewcvs.py/perlunit/src/Test-Unit/lib/Test/Unit/Assert.pm http://cvs.sourceforge.net/viewcvs.py/perlunit/src/Test-Unit/t/tlib/AssertTest.pm once the public repository has updated. The patch provides new assertions like this, my $object = Horse->new("Dobbin"); $self->assert_isa('Horse', $object); $self->assert_can('gallop', $object); and what I'm wondering is whether folks expect these to pass classnames in addition to instances of the classes, $self->assert_isa('Horse', 'Horse::Shire'); $self->assert_can('gallop', 'Horse'); when @Horse::Shire::ISA = ('Horse') . There are several options, 1) accept classnames as well as objects, to match the behaviour of UNIVERSAL::isa and UNIVERSAL::can 2) don't accept classnames because that's less likely to be useful in testing - this is what Marek's original code does 3) same as 2) but change the names to assert_objisa and assert_objcan For now I've left the code doing 2) but the installation tests require 1), so this will need resolving one way or another before the next release. It seemed best to ask the users what they expect the code to do... Other questions that might arise later are do we need assert_not_isa and assert_not_can? or some way to make composite assertions, that would make this easier? do we need to break Test::Unit::Assert or its POD down into smaller pieces to make it less scary? Suggestions welcome. Matthew #8-) |