4529e5502def9b541fc33f20b7f07aebf48542de
[scpubgit/Object-Remote.git] / t / basic.t
1 use strictures 1;
2 use Test::More;
3 use Sys::Hostname qw(hostname);
4
5 use Object::Remote::Connector::Local;
6 use Object::Remote;
7
8 $ENV{PERL5LIB} = join(
9   ':', ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : ()), qw(lib t/lib)
10 );
11
12 my $connection = Object::Remote::Connector::Local->new->connect;
13
14 #$Object::Remote::Connection::DEBUG = 1;
15
16 my $remote = Object::Remote->new(
17   connection => $connection,
18   class => 'ORTestClass'
19 );
20
21 isnt($$, $remote->pid, 'Different pid on the other side');
22
23 is($remote->counter, 0, 'Counter at 0');
24
25 is($remote->increment, 1, 'Increment to 1');
26
27 is($remote->counter, 1, 'Counter at 1');
28
29 my $x = 0;
30
31 is($remote->call_callback(27, sub { $x++ }), 27, "Callback ok");
32
33 is($x, 1, "Callback called callback");
34
35 is(
36   $connection->get_remote_sub('Sys::Hostname::hostname')->(),
37   hostname(),
38   'Remote sub call ok'
39 );
40
41 done_testing;