File: transfer.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 (61 lines) | stat: -rw-r--r-- 1,786 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use strictures 1;
use Test::More;
use Test::Fatal;
use FindBin;

$ENV{OBJECT_REMOTE_TEST_LOGGER} = 1;

$ENV{PERL5LIB} = join(
  ':', ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : ()), qw(lib t/lib)
);

use Object::Remote;

my $strA = 'foo';
my $strB = 'bar';

is exception {
  my $proxy = ORTestTransfer->new::on('-', value => \$strA);
  is_deeply $proxy->value, \$strA, 'correct value after construction';
}, undef, 'scalar refs - no errors during construction';

is exception {
  my $proxy = ORTestTransfer->new::on('-');
  $proxy->value(\$strB);
  is_deeply $proxy->value, \$strB, 'correct value after construction';
}, undef, 'scalar refs - no errors during attribute set';

my $data_file = "$FindBin::Bin/data/numbers.txt";

is exception {
  my $out = '';
  open my $fh, '>', \$out or die "Unable to open in-memory file: $!\n";
  my $proxy = ORTestGlobs->new::on('-', handle => $fh);
  ok $proxy->handle, 'filehandle was set';
  ok $proxy->write('foo'), 'write was successful';
  is $out, 'foo', 'write reached target';
}, undef, 'filehandles - no error during construction';

is exception {
  my $proxy = ORTestGlobs->new::on('-');
  my $handle = $proxy->gethandle;
  print $handle 'foo';
  is $proxy->getvalue, 'foo', 'correct value written';
  $handle->autoflush(1);
}, undef, 'filehandles - no error during remote handle';

is exception {
  my $proxy = ORTestGlobs->new::on('-');
  my $rhandle = $proxy->getreadhandle($data_file);
  my @lines = <$rhandle>;
  chomp @lines;
  is_deeply \@lines, [1 .. 5], 'reading back out of the handle';
}, undef, 'filehandles - no error during remote read';

is exception {
  my $proxy = ORTestGlobs->new::on('-');
  my $rhandle = $proxy->getreadhandle($data_file);
  binmode $rhandle;
}, undef, 'filehandles - no errors during binmode';

done_testing;