Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resolve rt #43126, reported by Steltie. Object states weren't

working, but his suggestion fixes it.  Also expanded the tests to
verify that object states are working.
  • Loading branch information...
commit b93a3097be4890cc8ed2ebc2dadf797a59753dd7 1 parent 4cb9f00
@rcaputo authored
Showing with 44 additions and 11 deletions.
  1. +2 −1  trunk/Makefile.PL
  2. +4 −3 trunk/MessageBased.pm
  3. +38 −7 trunk/t/01_basic.t
View
3  trunk/Makefile.PL
@@ -24,6 +24,7 @@ WriteMakefile(
),
},
PREREQ_PM => {
- 'POE' => 0.31,
+ 'POE' => 0.31,
+ 'Test::More' => 0,
},
);
View
7 trunk/MessageBased.pm
@@ -14,7 +14,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '0.01';
+$VERSION = '0.10';
use POE;
use base qw(POE::Session);
@@ -85,7 +85,7 @@ sub _invoke_state {
undef, # object
$self, # session
$POE::Kernel::poe_kernel, # kernel
- $self->[POE::Session::SE_NAMESPACE], # heap
+ $self->[POE::Session::SE_NAMESPACE], # heap
$state, # state
$source_session, # sender
undef, # unused #6
@@ -101,9 +101,10 @@ sub _invoke_state {
my ($object, $method) = @{$self->[POE::Session::SE_STATES]->{$state}};
my $message = POE::Session::Message->new(
+ $object, # object
$self, # session
$POE::Kernel::poe_kernel, # kernel
- $self->[POE::Session::SE_NAMESPACE], # heap
+ $self->[POE::Session::SE_NAMESPACE], # heap
$state, # state
$source_session, # sender
undef, # unused #6
View
45 trunk/t/01_basic.t
@@ -7,30 +7,61 @@ use strict;
use lib './blib/lib';
use lib '../blib/lib';
+use Test::More tests => 22;
use POE::Kernel;
use POE::Session::MessageBased;
-print "1..11\n";
-
POE::Session::MessageBased->create(
inline_states => {
_start => sub {
my ($message, @params) = @_;
- print "not " unless $message->isa("POE::Session::Message");
- print "ok 1\n";
+ ok($message->isa("POE::Session::Message"), "inline message is ok");
$message->kernel->yield( count => 2 );
},
count => sub {
my ($message, $count) = @_;
- print "ok $count\n";
+ pass("inline got count $count");
if ($count < 10) {
$message->kernel->yield( count => ++$count );
}
},
_stop => sub {
- print "ok 11\n";
+ pass("inline test stopped");
}
},
);
-$poe_kernel->run();
+POE::Session::MessageBased->create(
+ object_states => [
+ main->new() => {
+ _start => "_poe_handle_start",
+ count => "_poe_handle_count",
+ _stop => "_poe_handle_stop",
+ }
+ ],
+);
+
+POE::Kernel->run();
+exit;
+
+sub new { return bless {}, shift }
+
+sub _poe_handle_start {
+ my ($self, $message, @params) = @_;
+ die unless ref($message->object) eq "main";
+ ok($message->isa("POE::Session::Message"), "object message is ok");
+ $message->kernel->yield( count => 13 );
+}
+
+sub _poe_handle_count {
+ my ($self, $message, $count) = @_;
+ die unless ref($message->object) eq "main";
+ pass("object counter $count");
+ if ($count < 21) {
+ $message->kernel->yield( count => ++$count );
+ }
+}
+
+sub _poe_handle_stop {
+ pass("object test stopped");
+}
Please sign in to comment.
Something went wrong with that request. Please try again.