Skip to content

Commit

Permalink
add test for anonymous event handler args
Browse files Browse the repository at this point in the history
  • Loading branch information
preaction committed Mar 8, 2015
1 parent 0fd065d commit 0b3b427
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions t/14_on_event.t
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ subtest 'anonymous listeners' => sub {
on => {
greet => {
'$class' => 'My::Listener',
'$args' => {
attribute => 'foo',
},
'$sub' => 'on_greet',
},
},
Expand All @@ -133,6 +136,7 @@ subtest 'anonymous listeners' => sub {

$svc->emit( 'greet' );
is $My::Listener::LAST_CREATED->events_seen, 1;
is $My::Listener::LAST_CREATED->attribute, 'foo';
};

subtest '$extends' => sub {
Expand Down
4 changes: 4 additions & 0 deletions t/lib/My/Listener.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ has events_seen => (
default => sub { 0 },
);

has attribute => (
is => 'ro',
);

sub on_greet {
my ( $self ) = @_;
$self->events_seen( $self->events_seen + 1 );
Expand Down

0 comments on commit 0b3b427

Please sign in to comment.