Skip to content

Commit

Permalink
better unsubscribe tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 29, 2013
1 parent b98b86e commit 5f19dfc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions t/mojo/eventemitter.t
Expand Up @@ -22,10 +22,7 @@ eval { $e->emit_safe(error => 'works') };
like $@, qr/^Mojo::EventEmitter: works/, 'right error';

# Exception in error event
ok !$e->has_subscribers('error'), 'no subscribers';
$e->once(error => sub { die "$_[1]entional" });
$e->unsubscribe(error => sub { });
ok $e->has_subscribers('error'), 'has subscribers';
eval { $e->emit(error => 'int') };
like $@, qr/^intentional/, 'right error';
$e->once(error => sub { die "$_[1]entional" });
Expand Down Expand Up @@ -73,6 +70,8 @@ is $called, 3, 'event was not emitted again';
my $once;
$e->once(one_time => sub { $once++ });
is scalar @{$e->subscribers('one_time')}, 1, 'one subscriber';
$e->unsubscribe(one_time => sub { });
is scalar @{$e->subscribers('one_time')}, 1, 'one subscriber';
$e->emit('one_time');
is $once, 1, 'event was emitted once';
is scalar @{$e->subscribers('one_time')}, 0, 'no subscribers';
Expand Down

0 comments on commit 5f19dfc

Please sign in to comment.