File Coverage

blib/lib/Acme/Oil/ed/Array.pm
Criterion Covered Total %
statement 44 49 89.8
branch 11 16 68.7
condition 1 3 33.3
subroutine 10 12 83.3
pod n/a
total 66 80 82.5


line stmt bran cond sub pod time code
1             ##############################################################################
2             package Acme::Oil::ed::Array;
3              
4 1     1   5 use warnings;
  1         2  
  1         32  
5 1     1   4 use strict;
  1         2  
  1         30  
6 1     1   4 use Carp;
  1         2  
  1         61  
7 1     1   4 use base qw(Tie::Array Acme::Oil::ed);
  1         1  
  1         754  
8              
9              
10             sub TIEARRAY {
11 3     3   5 my $class = shift;
12 3         20 my @array = @_;
13 3         11 my $self = {
14             value => [@array],
15             level => 80,
16             };
17 3         13 bless $self, $class;
18             }
19              
20              
21             sub FETCH {
22 23     23   122 my ($self,$index) = @_;
23              
24 23 100       64 if( $self->is_slipped(1, 1) ){
25 11         22 my $rand = rand($self->FETCHSIZE + 1);
26 11 50 33     2319 carp "Can't be taken out well by your hand's slipping."
27             if($rand ne $index and warnings::enabled('Acme::Oil'));
28 11         5818 return $self->{value}[$rand];
29             }
30              
31 12         32 $self->{value}[$index];
32             }
33              
34              
35             sub STORE {
36 33     33   103 my ($self, $index, $value) = @_;
37              
38 33 100       92 if(Acme::Oil::_is_burning($value)){
39 1         9 $self->ignition();
40 1         4 return;
41             }
42              
43 32 100       84 if( $self->is_slipped(0.3, 0.5) ){
44 8 50       1603 carp "Can't be put well by your hand's slipping."
45             if(warnings::enabled('Acme::Oil'));
46              
47 8         574 my $rand = rand($self->FETCHSIZE + 1);
48              
49 8 50       14 if( $rand < $self->FETCHSIZE ){
50 8         14 $self->{value}[$rand] = $value;
51             }
52              
53 8         25 return;
54             }
55              
56 24         81 $self->{value}[$index] = $value;
57             }
58              
59              
60             sub FETCHSIZE {
61 33     33   93 my $self = shift;
62 33         31 scalar @{ $self->{value} };
  33         602  
63             }
64              
65              
66             sub STORESIZE {
67 3     3   9 my $self = shift;
68 3         3 my $num = shift;
69 3         5 $#{ $self->{value} } = $num - 1;
  3         11  
70             }
71              
72             sub EXISTS {
73 0     0   0 my ($self, $index) = @_;
74 0         0 exsits $self->{value}[$index];
75             }
76              
77             sub DELETE {
78 0     0   0 my ($self, $index) = @_;
79 0         0 delete $self->{value}[$index];
80             }
81              
82              
83             sub CLEAR {
84 1     1   1 my $self = shift;
85              
86 1 50       8 if( $self->is_slipped(1, 1) ){
87 1 50       287 carp "Can't be clear by your hand's slipping."
88             if(warnings::enabled('Acme::Oil'));
89 1         38 return;
90             }
91              
92 0           $self->STORESIZE(0);
93             }
94              
95              
96              
97              
98              
99             1;
100             __END__