[Pdx-pm] Poll: traits

Kris Bosland krisb at ring.org
Sat Nov 19 14:07:55 PST 2005

On Sat, 19 Nov 2005, Ovid wrote:

>   sub fuse {
>     my ($self, $time) = @_;
>     $self->set_igniter($time);
>     $self->explode;
>   }
> Where does the set_igniter() method come from?  It might be provided in
> the TBomb trait, but if you want to have a variety of applicable
> igniters, you can add this:
>   our @REQUIRES = qw(set_igniter);
> Now, TBomb does not have to provide its own implementation, but you
> can't use it unless *something* provides that.  Again, it fails at
> compile time.

	Hey, something I have been thinking of recently is to try to
figure out some way to create an interface test widget in between two
classes or libraries.  Some kind of mirrored thing that:

1. Tests that the library you use acts like you expect
2. Provides a reciprocal dummy object that can test your library

Something like:

package BombInterface;
use TestInterface;


BombInterface->testInterface() does:
	ok_defined(my $b = Bomb->new());

my $b = BombInterface->stubInterface()
$b->fuse(); #"Boom!"

can be used in the tests of the class using Bomb.


More information about the Pdx-pm-list mailing list