summaryrefslogtreecommitdiff
path: root/test.pl
diff options
context:
space:
mode:
Diffstat (limited to 'test.pl')
-rwxr-xr-xtest.pl29
1 files changed, 19 insertions, 10 deletions
diff --git a/test.pl b/test.pl
index a5aea3c..54884ba 100755
--- a/test.pl
+++ b/test.pl
@@ -30,9 +30,10 @@ ok !Tanja::match([2], [1]);
my $done = AnyEvent->condvar;
my $n = 0;
my $n2 = 0;
- $ses->reg([], 0, sub {
+ $ses->reg([], sub {
my($t, $r) = @_;
- is $r, undef;
+ isa_ok $r, 'Tanja::ReturnPath';
+ ok $r->null;
is_deeply $t, [$n];
ok $n <= 5;
if(++$n == 5) {
@@ -40,9 +41,10 @@ ok !Tanja::match([2], [1]);
$done->send;
}
});
- $ses->reg_once([undef], 0, sub {
+ $ses->reg_once([undef], sub {
my($t, $r) = @_;
- is $r, undef;
+ isa_ok $r, 'Tanja::ReturnPath';
+ ok $r->null;
is_deeply $t, [0];
$n2++;
});
@@ -55,26 +57,33 @@ ok !Tanja::match([2], [1]);
}
-# Simple double-session test
+# Simple double-session test with return-path
{
my $serv = Tanja::Server->new;
my $a = $serv->session;
my $b = $serv->session;
my $done = AnyEvent->condvar;
- $a->reg(["msg"], 0, sub {
+ $a->reg(["msg"], sub {
my($t, $r) = @_;
- is $r, undef;
+ isa_ok $r, 'Tanja::ReturnPath';
+ ok !$r->null;
+ $r->reply(['b', 9]);
is_deeply $t, ["msg", 'a'];
$a->send(["b"]);
});
- $b->reg(["b"], 0, sub {
+ $b->reg(["b"], sub {
my($t, $r) = @_;
- is $r, undef;
+ isa_ok $r, 'Tanja::ReturnPath';
+ ok $r->null;
is_deeply $t, ["b"];
$done->send;
});
- $b->send(["msg", 'a']);
+ my $n = 0;
+ $b->send(["msg", 'a'], sub {
+ !$n++ ? is_deeply $_[0], ['b', 9] : ok !@_;
+ });
$done->recv;
+ is $n, 2;
}