X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=t%2Fstart_core.t;h=964a103d1e69a3ba634276ed35ee1b69af6ee6e5;hp=31d5349eecb6c7ab2f9385dc6e6636170b002b40;hb=0e090a216bf8825855f8ca70bcb7f0980b5f786d;hpb=11e7c8a508b90595385fe78e9036f8f8313d9dbd diff --git a/t/start_core.t b/t/start_core.t index 31d5349..964a103 100644 --- a/t/start_core.t +++ b/t/start_core.t @@ -1,5 +1,9 @@ use strictures 1; use Test::More; +use Object::Remote; +use File::Spec; + +require 't/logsetup.pl'; { package S1S; @@ -20,9 +24,13 @@ use Test::More; our $C; sub get_s2 { + shift->maybe::start::_real_get_s2; + } + + sub _real_get_s2 { future { my $f = shift; - $C = sub { $f->done(S2F->new); undef($f); }; + $C = sub { $f->done(S2F->new); undef($f); undef($C); }; $f; } } @@ -47,7 +55,7 @@ use Test::More; sub get_s3 { future { my $f = shift; - $C = sub { $f->done('S3'); undef($f); }; + $C = sub { $f->done('S3'); undef($f); undef($C); }; $f; } } @@ -75,4 +83,19 @@ $S2F::C->(); is($res, 'S3', 'Asynchronous code ok'); +is(S1S->get_s2->get_s3, 'S3', 'Sync without start'); + +Object::Remote->current_loop->watch_time( + after => 0.1, + code => sub { + $S1F::C->(); + Object::Remote->current_loop->watch_time( + after => 0.1, + code => sub { $S2F::C->() } + ); + } +); + +is(S1F->get_s2->get_s3, 'S3', 'Async without start'); + done_testing;