Commit | Line | Data |
f129bfaf |
1 | use strictures 1; |
2 | use Test::More; |
3 | |
4 | use lib 't/lib'; |
5 | |
6 | use Tie::Array; |
7 | use Tie::Hash; |
8 | |
9 | require 't/logsetup.pl'; |
10 | |
11 | use Object::Remote; |
12 | use ORTestTiedRemote; |
13 | |
14 | my @test_data = qw(1 5 10 30 80); |
15 | my $test_sum; |
16 | |
17 | map { $test_sum += $_ } @test_data; |
18 | |
19 | my $conn = Object::Remote->connect('-'); |
20 | my $remote = ORTestTiedRemote->new::on($conn); |
21 | |
22 | isa_ok($remote, 'Object::Remote::Proxy'); |
23 | |
24 | my $remote_array = $remote->array; |
25 | my $remote_hash = $remote->hash; |
26 | |
27 | is(ref($remote_array), 'ARRAY', 'Array ref is array ref'); |
28 | is(ref(tied(@$remote_array)), 'Object::Remote::Proxy', 'Array is tied to proxy object'); |
29 | is_deeply($remote_array, ['another value'], 'Array is initialized properly'); |
30 | |
31 | @$remote_array = @test_data; |
32 | is($remote->sum_array, $test_sum, 'Sum of array data matches sum of test data'); |
33 | |
34 | is(ref($remote_hash), 'HASH', 'Hash ref is hash ref'); |
35 | is(ref(tied(%$remote_hash)), 'Object::Remote::Proxy', 'Hash is tied to proxy object'); |
36 | is_deeply($remote_hash, { akey => 'a value' }, 'Hash is initialized properly'); |
37 | |
38 | %$remote_hash = (); |
39 | do { my $i = 0; map { $remote_hash->{++$i} = $_ } @test_data }; |
40 | is($remote->sum_hash, $test_sum, 'Sum of hash values matches sum of test data'); |
41 | |
42 | done_testing; |
43 | |
44 | |
45 | |