Commit | Line | Data |
542d5b5c |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
abef6e5b |
4 | $ENV{OBJECT_REMOTE_TEST_LOGGER} = 1; |
f129bfaf |
5 | |
542d5b5c |
6 | use Object::Remote::Connector::Local; |
7 | use Object::Remote; |
8 | use Object::Remote::ModuleSender; |
9 | |
10 | $ENV{PERL5LIB} = join( |
11 | ':', ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : ()), qw(lib) |
12 | ); |
13 | |
e8ba6092 |
14 | my $mod_content = do { |
15 | open my $fh, '<', 't/lib/ORTestClass.pm' |
16 | or die "can't read ORTestClass.pm: $!"; |
17 | local $/; |
18 | <$fh> |
19 | }; |
20 | my $modules = { |
21 | 'ORTestClass.pm' => $mod_content, |
22 | }; |
542d5b5c |
23 | |
e8ba6092 |
24 | sub TestModuleProvider::INC { |
25 | my ($self, $module) = @_; |
26 | if (my $data = $self->{modules}{$module}) { |
27 | open my $fh, '<', \$data |
28 | or die "welp $!"; |
29 | return $fh; |
30 | } |
31 | return; |
32 | } |
542d5b5c |
33 | |
e8ba6092 |
34 | my %sources = ( |
35 | basic => [ 't/lib' ], |
36 | sub => [ sub { |
37 | if (my $data = $modules->{$_[1]}) { |
38 | open my $fh, '<', \$data |
39 | or die "welp $!"; |
40 | return $fh; |
41 | } |
42 | return; |
43 | } ], |
44 | dynamic_array => [ [ sub { |
45 | my $mods = $_[0][1]; |
46 | if (my $data = $mods->{$_[1]}) { |
47 | open my $fh, '<', \$data |
48 | or die "welp $!"; |
49 | return $fh; |
50 | } |
51 | return; |
52 | }, $modules ] ], |
53 | object => [ bless { modules => $modules }, 'TestModuleProvider' ], |
676438a1 |
54 | ); |
542d5b5c |
55 | |
e8ba6092 |
56 | for my $source (sort keys %sources) { |
57 | my $ms = Object::Remote::ModuleSender->new( |
58 | dir_list => $sources{$source}, |
59 | ); |
60 | my $connection = Object::Remote::Connector::Local->new( |
61 | module_sender => $ms, |
62 | )->connect; |
63 | |
64 | my $counter = Object::Remote->new( |
65 | connection => $connection, |
66 | class => 'ORTestClass' |
67 | ); |
68 | |
69 | isnt($$, $counter->pid, "$source sender: Different pid on the other side"); |
542d5b5c |
70 | |
e8ba6092 |
71 | is($counter->counter, 0, "$source sender: Counter at 0"); |
542d5b5c |
72 | |
e8ba6092 |
73 | is($counter->increment, 1, "$source sender: Increment to 1"); |
542d5b5c |
74 | |
e8ba6092 |
75 | is($counter->counter, 1, "$source sender: Counter at 1"); |
76 | } |
542d5b5c |
77 | |
78 | done_testing; |