File: tied.t

package info (click to toggle)
libobject-remote-perl 0.004000-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 488 kB
  • ctags: 248
  • sloc: perl: 2,408; makefile: 7
file content (43 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use strictures 1;
use Test::More;

use lib 't/lib';

use Tie::Array;
use Tie::Hash;

$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1;

use Object::Remote;
use ORTestTiedRemote;

my @test_data = qw(1 5 10 30 80);
my $test_sum;

map { $test_sum += $_ } @test_data;

my $conn = Object::Remote->connect('-');
my $remote = ORTestTiedRemote->new::on($conn);

isa_ok($remote, 'Object::Remote::Proxy');

my $remote_array = $remote->array;
my $remote_hash = $remote->hash;

is(ref($remote_array), 'ARRAY', 'Array ref is array ref');
is(ref(tied(@$remote_array)), 'Object::Remote::Proxy', 'Array is tied to proxy object');
is_deeply($remote_array, ['another value'], 'Array is initialized properly');

@$remote_array = @test_data;
is($remote->sum_array, $test_sum, 'Sum of array data matches sum of test data');

is(ref($remote_hash), 'HASH', 'Hash ref is hash ref');
is(ref(tied(%$remote_hash)), 'Object::Remote::Proxy', 'Hash is tied to proxy object');
is_deeply($remote_hash, { akey => 'a value' }, 'Hash is initialized properly');

%$remote_hash = ();
do { my $i = 0; map { $remote_hash->{++$i} = $_ } @test_data };
is($remote->sum_hash, $test_sum, 'Sum of hash values matches sum of test data');

done_testing;