Spy/TieScalar.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 41 CC 1 SCAR 6.9
CC
1
Cov
0%
TIESCALAR
2.0
FETCH
2.0
STORE
2.0
CRAP 2.0
1 package Devel::Spy::TieScalar;
2 use strict;
3 use warnings;
4  
5 use constant PAYLOAD => 0;
6 use constant CODE => 1;
7  
8 sub TIESCALAR {
9 my $class = shift @_;
10  
11 my @self;
12 @self[ PAYLOAD, CODE, ] = @_;
13  
14 return bless \@self, $class;
15 }
16  
17 sub FETCH {
18 my $self = shift @_;
19  
20 my $value = ${ $self->[PAYLOAD] };
21  
22 my $followup = $self->[CODE]->("-> $value");
23  
24 return Devel::Spy->new( $value, $followup );
25 }
26  
27 sub STORE {
28 my ( $self, $value ) = @_;
29  
30 ${ $self->[PAYLOAD] } = $value;
31  
32 my $followup = $self->[CODE]->("= $value");
33  
34 return Devel::Spy->new( $value, $followup );
35 }
36  
37 sub UNTIE {}
38 sub DESTROY {}
39  
40 1;
41  
42 __END__