File Coverage

blib/lib/Rose/HTML/Object/WithWrapAroundChildren.pm
Criterion Covered Total %
statement 26 26 100.0
branch 11 16 68.7
condition n/a
subroutine 8 8 100.0
pod 0 5 0.0
total 45 55 81.8


line stmt bran cond sub pod time code
1              
2             use strict;
3 13     13   83  
  13         25  
  13         377  
4             use Carp;
5 13     13   56  
  13         26  
  13         1661  
6             our $VERSION = '0.554';
7              
8             use Rose::HTML::Object::MakeMethods::Generic
9             (
10             array =>
11 13         231 [
12             'pre_children' => {},
13             'shift_pre_children' => { interface => 'shift', hash_key => 'pre_children' },
14             'unshift_pre_children' => { interface => 'unshift', hash_key => 'pre_children' },
15             'pop_pre_children' => { interface => 'pop', hash_key => 'pre_children' },
16             'push_pre_children' => { interface => 'push', hash_key => 'pre_children' },
17             'delete_pre_children' => { interface => 'clear', hash_key => 'pre_children' },
18              
19             'post_children' => {},
20             'shift_post_children' => { interface => 'shift', hash_key => 'post_children' },
21             'unshift_post_children' => { interface => 'unshift', hash_key => 'post_children' },
22             'push_post_children' => { interface => 'push', hash_key => 'post_children' },
23             'pop_post_children' => { interface => 'pop', hash_key => 'post_children' },
24             'delete_post_children' => { interface => 'clear', hash_key => 'post_children' },
25             ],
26             );
27 13     13   100  
  13         28  
28             {
29             my($self) = shift;
30             Carp::croak "Cannot directly set children() for a ", ref($self),
31 1197     1197 0 1799 ". Use fields(), push_children(), pop_children(), etc." if(@_);
32 1197 50       2008 return wantarray ? ($self->pre_children, $self->immutable_children(), $self->post_children) :
33             [ $self->pre_children, $self->immutable_children(), $self->post_children ];
34 1197 100       2789 }
35              
36              
37             {
38 4     4 0 19 my($self) = shift;
39              
40             my $num = @_ ? shift : 1;
41             my @children = $self->pop_post_children($num);
42 4     4 0 8  
43             if(@children < $num)
44 4 50       13 {
45 4         15 push(@children, $self->pop_pre_children($num - @children));
46             }
47 4 100       11  
48             return @children == 1 ? $children[0] : @children;
49 1         8 }
50              
51             {
52 4 50       20 my($self) = shift;
53              
54             my $num = @_ ? shift : 1;
55             my @children = $self->shift_pre_children($num);
56              
57 2     2 0 3 if(@children < $num)
58             {
59 2 50       6 push(@children, $self->shift_post_children($num - @children));
60 2         7 }
61              
62 2 100       6 return @children == 1 ? $children[0] : @children;
63             }
64 1         10  
65              
66             1;