[Perlunit-devel] Problem with namespace
Status: Beta
Brought to you by:
mca1001
|
From: jonasbn <jo...@wa...> - 2002-02-21 21:45:36
|
As promised - my example:
package Class::EmployeeTest;
use strict;
use vars qw(@ISA);
use base qw(Test::Unit::TestCase);
sub new {
my $self = shift()->SUPER::new(@_);
$self->{'_name'} = '';
$self->{'_department'} = '';
return $self;
}
sub set_up {
my $self = shift;
$self->{'_name'} = 'Arne Raket';
$self->{'_department'} = 'dA pErl lAb';
}
sub test_name {
my $self = shift;
my $name = $self->{_name};
$self->assert($name eq 'Arne Raket');
}
sub test_department {
my $self = shift;
my $department = $self->{'_department'};
$self->assert($department eq 'dA pErl lAb');
}
1;
The name (_name) field clashes, I guess that name is probably the most used
field in OOP. It should therefore not be used in Test::Unit::TestCase.
I have made a brief workaround (see the attached patch).
Changing the internal field to Test::Unit::TestCase::_name_of_test is not a
valid solution though :-/
So a proper namespace protection scheme should be implemented. I have tried to
fool around with this (using Tie::Securehash) without any luck, since the
Assert.pm tries to access the _no_backtrace_on_fail at runtime.
Either the component structure should be change or a different scheme should be chosen.
jonasbn
--
Eml: jo...@wa... || ICQ: 62401545
WWW: http://jonasbn.hjem.wanadoo.dk/
|