| ☞ | Program
Repair Shop ![]() |
63 |
For example:
my $baz_b = Baz->new;
is( $baz_b->add_observer( \&observer_c ), 1 );
$baz_b->yell;
is( $observations[3], "Observation C from [Baz]" );
is( $observations[4], "Observation B from [Baz]" );
is( $observations[5], "Observation A from [Baz]" );
This requires that observer C be notified first
Is that a requirement?
The manual doesn't say anything about the order in which observers are notified
I changed this to:
@observations = ();
my $baz_b = Baz->new;
is( $baz_b->add_observer( \&observer_c ), 1 );
$baz_b->yell;
@observations = sort @observations;
is( $observations[0], "Observation A from [Baz]" );
is( $observations[1], "Observation B from [Baz]" );
is( $observations[2], "Observation C from [Baz]" );
(2016 addendum: These days I would use
use Test::Deep;
cmp_deeply(\@observations,
bag(map "Observation $_ from [Baz]", qw(A B C)));
but we didn't have it then.)
| ☞ | ![]() |
☞ |