File Coverage

blib/lib/Language/P/Toy/Value/Handle.pm
Criterion Covered Total %
statement 15 18 83.3
branch 2 6 33.3
condition n/a
subroutine 4 5 80.0
pod 0 2 0.0
total 21 31 67.7


line stmt bran cond sub pod time code
1             package Language::P::Toy::Value::Handle;
2              
3 100     100   550 use strict;
  100         209  
  100         3388  
4 100     100   558 use warnings;
  100         202  
  100         13598  
5 100     100   519 use base qw(Language::P::Toy::Value::Any);
  100         193  
  100         25385  
6              
7             __PACKAGE__->mk_ro_accessors( qw(handle) );
8              
9 0     0 0 0 sub type { 4 }
10              
11             sub write {
12 113     113 0 192 my( $self, $scalar, $offset, $length ) = @_;
13 113         396 local $\;
14              
15 113         388 my $buffer = $scalar->as_string;
16 113 50       300 if( defined $offset ) {
17 0 0       0 print { $self->handle } defined( $length ) ?
  0         0  
18             substr( $buffer, $offset, $length ) :
19             substr( $buffer, $offset );
20             } else {
21 113 50       149 print { $self->handle } defined( $length ) ?
  113         503  
22             substr( $buffer, 0, $length ) :
23             $buffer;
24             }
25             }
26              
27             1;