2b5473b7a34157e9816a00b3f0d7e65ec56bee89
[scpubgit/Object-Remote.git] / t / reconnect.t
1 use strictures 1;
2 use Test::More;
3
4 use Object::Remote;
5 use Object::Remote::FromData;
6
7 my $conn1 = Reconnector->new::on('-');
8 my $conn2 = $conn1->connect;
9
10 isa_ok($conn1, 'Object::Remote::Proxy');
11 isa_ok($conn2, 'Object::Remote::Proxy');
12
13 my $root_pid = $$;
14 my $conn1_pid = $conn1->pid;
15 my $conn2_pid = $conn2->pid;
16
17 ok($root_pid != $conn1_pid, "Root and conn1 are not the same interpreter instance");
18 ok($root_pid != $conn2_pid, "Root and conn2 are not the same interpreter instance");
19 ok($conn1_pid != $conn2_pid, "conn1 and conn2 are not the same interpreter instance");
20
21 ok($conn1->ping eq "pong", "Ping success on conn1");
22 ok($conn2->ping eq "pong", "Ping success on conn2");
23
24 done_testing;
25
26 __DATA__
27
28 package Reconnector;
29
30 use Moo;
31
32 sub connect {
33   return Reconnector->new::on('-');
34 }
35
36 sub pid {
37   return $$;
38 }
39
40 sub ping {
41   return 'pong';
42 }