Exclude vendorarch and sitearch from FatNode and ModuleSender
[scpubgit/Object-Remote.git] / t / transfer.t
CommitLineData
6ed5d580 1use strictures 1;
2use Test::More;
3use Test::Fatal;
ed5a8a8e 4use FindBin;
6ed5d580 5
6$ENV{PERL5LIB} = join(
7 ':', ($ENV{PERL5LIB} ? $ENV{PERL5LIB} : ()), qw(lib t/lib)
8);
9
10use Object::Remote;
11
12my $strA = 'foo';
13my $strB = 'bar';
14
15is exception {
16 my $proxy = ORTestTransfer->new::on('-', value => \$strA);
17 is_deeply $proxy->value, \$strA, 'correct value after construction';
ed5a8a8e 18}, undef, 'scalar refs - no errors during construction';
6ed5d580 19
20is exception {
21 my $proxy = ORTestTransfer->new::on('-');
22 $proxy->value(\$strB);
23 is_deeply $proxy->value, \$strB, 'correct value after construction';
ed5a8a8e 24}, undef, 'scalar refs - no errors during attribute set';
25
26my $data_file = "$FindBin::Bin/data/numbers.txt";
27
28is exception {
29 my $out = '';
30 open my $fh, '>', \$out or die "Unable to open in-memory file: $!\n";
31 my $proxy = ORTestGlobs->new::on('-', handle => $fh);
32 ok $proxy->handle, 'filehandle was set';
33 ok $proxy->write('foo'), 'write was successful';
34 is $out, 'foo', 'write reached target';
35}, undef, 'filehandles - no error during construction';
36
37is exception {
38 my $proxy = ORTestGlobs->new::on('-');
39 my $handle = $proxy->gethandle;
40 print $handle 'foo';
41 is $proxy->getvalue, 'foo', 'correct value written';
42 $handle->autoflush(1);
43}, undef, 'filehandles - no error during remote handle';
44
45is exception {
46 my $proxy = ORTestGlobs->new::on('-');
47 my $rhandle = $proxy->getreadhandle($data_file);
48 my @lines = <$rhandle>;
49 chomp @lines;
50 is_deeply \@lines, [1 .. 5], 'reading back out of the handle';
51}, undef, 'filehandles - no error during remote read';
52
53is exception {
54 my $proxy = ORTestGlobs->new::on('-');
55 my $rhandle = $proxy->getreadhandle($data_file);
56 binmode $rhandle;
57}, undef, 'filehandles - no errors during binmode';
6ed5d580 58
59done_testing;