Skip to content

Commit

Permalink
fixed localization bug in Mojo::EventEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 11, 2013
1 parent 30fb8a8 commit a7f4185
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

3.77 2013-01-11
- Improved tests.
- Fixed localization bug in Mojo::EventEmitter.
- Fixed small upgrade bugs in Mojo::UserAgent::Transactor.

3.76 2013-01-10
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/EventEmitter.pm
Expand Up @@ -10,7 +10,7 @@ sub emit {

if (my $s = $self->{events}{$name}) {
warn "-- Emit $name in @{[blessed($self)]} (@{[scalar(@$s)]})\n" if DEBUG;
$self->$_(@_) for @$s;
for my $cb (@$s) { $self->$cb(@_) }
}
else {
warn "-- Emit $name in @{[blessed($self)]} (0)\n" if DEBUG;
Expand Down
6 changes: 3 additions & 3 deletions t/mojo/eventemitter.t
Expand Up @@ -136,16 +136,16 @@ is scalar @{$e->subscribers('foo')}, 0, 'no subscribers';
$e->emit('foo');
is $counter, 5, 'event was not emitted again';

# Pass by reference
# Pass by reference and assignment to $_
$e = Mojo::EventEmitter->new;
my $buffer = '';
$e->on(one => sub { $_[1] .= 'abc' . $_[2] });
$e->on(one => sub { $_ = $_[1] .= 'abc' . $_[2] });
$e->on(one => sub { $_[1] .= '123' . pop });
is $buffer, '', 'right result';
$e->emit(one => $buffer => 'two');
is $buffer, 'abctwo123two', 'right result';
$e->once(one => sub { $_[1] .= 'def' });
$e->emit(one => $buffer => 'three');
$e->emit_safe(one => $buffer => 'three');
is $buffer, 'abctwo123twoabcthree123threedef', 'right result';
$e->emit(one => $buffer => 'x');
is $buffer, 'abctwo123twoabcthree123threedefabcx123x', 'right result';
Expand Down

0 comments on commit a7f4185

Please sign in to comment.