From 7cf44d6313fa1d447e2c42e84a0db060cca87454 Mon Sep 17 00:00:00 2001 From: "Scott S. McCoy" Date: Wed, 12 Sep 2012 14:10:11 -0700 Subject: [PATCH] Added "Watching for published values" test. * Added a test "Watching for published values" which validates that one and only one invocation happens per watcher added for a value which is already published. * This test proved to not uncover any bug, which was partially expected, but now it's verified. --- t/01_watcher.t | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/t/01_watcher.t b/t/01_watcher.t index 9778c2c..f265abf 100644 --- a/t/01_watcher.t +++ b/t/01_watcher.t @@ -70,6 +70,30 @@ subtest "Add Watcher" => sub { $blackboard->put(foo => "foo", bar => "bar"); }; +=item Watching for published values. + +Establish whether or not duplicate dispatches occur when looking for values +that already are published to the blackboard. + +=cut + +subtest "Watching for published values." => sub { + plan tests => 3; + + my $blackboard = AnyEvent::Blackboard->new(); + my $okayer = okayer->new( + foo => "foo", + bar => "bar", + ); + + $blackboard->put(foo => "foo"); + $blackboard->put(bar => "bar"); + + $blackboard->watch([qw( foo bar )], [ $okayer, "foobar" ]); + $blackboard->watch(foo => [ $okayer, "foo" ]); + $blackboard->watch(bar => [ $okayer, "bar" ]); +}; + =item Default Timeout