Mixin-Event-Dispatch

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	rather than just the ones matching the requested coderef.

1.000     2012-09-22 11:52:51 Europe/London
	Provide Mixin::Event::Dispatch::Event class and a more advanced observer
	model via subscribe_to_event / unsubscribe_from_event.

0.004     2012-01-08 07:04:56 Europe/London
	Require a version of Test::More providing new_ok.

0.003     2011-07-05 18:22:39 Europe/London
	Check for PadWalker - without it, cycle tests fail

0.002     2011-07-05 07:15:51 Europe/London
	Add missing dependency on parent.pm for tests
	Rename event_stack to event_handlers since the original name was misleading (thanks mst)
	Fix typo in synopsis
	Add note about roles

0.001     2011-07-02 21:44:07 Europe/London
	Initial version.

t/cycle.t  view on Meta::CPAN

use parent qw(Mixin::Event::Dispatch);

sub new { bless {}, shift }
sub cycle_step { my $self = shift; 0; }

package main;
use Test::More;
use Scalar::Util qw(weaken);
if(!eval { require Test::Memory::Cycle; }) {
	plan skip_all => 'Test::Memory::Cycle not installed';
} elsif(!eval { require PadWalker; }) {
# need this as well otherwise we get this error in tests:
#  A code closure was detected in but we cannot check it unless the PadWalker module is installed
	plan skip_all => 'PadWalker not installed';
} else {
	Test::Memory::Cycle->import;
	plan tests => 7;
}

my $obj = new_ok('EventTest');
weaken (my $obj_weak = $obj);
ok($obj->add_handler_for_event('cycle' => sub { $obj->cycle_step }), 'add handler with cycle');
memory_cycle_exists($obj);
ok($obj->invoke_event('cycle'), 'run an event to clear handler');



( run in 0.836 second using v1.01-cache-2.11-cpan-05444aca049 )