File Coverage

blib/lib/OOP/Perlish/Class/Accessor/UnitTests/ArrayRef.pm
Criterion Covered Total %
statement 53 53 100.0
branch 2 4 50.0
condition n/a
subroutine 16 16 100.0
pod 0 4 0.0
total 71 77 92.2


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2 1     1   4 use warnings;
  1         2  
  1         30  
3 1     1   5 use strict;
  1         1  
  1         43  
4             {
5             package OOP::Perlish::Class::Accessor::UnitTests::ArrayRef;
6 1     1   4 use warnings;
  1         1  
  1         19  
7 1     1   4 use strict;
  1         2  
  1         31  
8 1     1   500 use OOP::Perlish::Class::Accessor::UnitTests::Array;
  1         5  
  1         38  
9 1     1   8 use base 'OOP::Perlish::Class::Accessor::UnitTests::Array';
  1         2  
  1         100  
10 1     1   6 use OOP::Perlish::Class::Accessor;
  1         2  
  1         7  
11 1     1   7 use Test::More;
  1         2  
  1         7  
12 1     1   314 use Data::Dumper;
  1         2  
  1         113  
13              
14             sub setup : Test(setup)
15             {
16 8     8 0 6211 my ($self) = @_;
17 8         88 $self->{accessor} = OOP::Perlish::Class::Accessor->new( type => 'ARRAYREF', name => 'test', self => bless( {}, __PACKAGE__ ) );
18 1     1   7 }
  1         2  
  1         16  
19              
20             sub get_value
21             {
22 9     9 0 20 my ($self) = @_;
23              
24 9         20 my @values = @{ $self->{accessor}->value() };
  9         46  
25 9         52 return( @values );
26             }
27              
28             sub cannot_mutate_reference : Test(1)
29             {
30 1     1 0 204 my ($self) = @_;
31              
32 1         6 $self->{accessor}->value('baz');
33 1         7 $self->{accessor}->value()->[1] = 'bar';
34 1 50       4 is(scalar(@{ $self->{accessor}->value() }), 1, 'cannot mutate instance reference' ) || diag(Dumper($self->{accessor}->value()));
  1         5  
35 1     1   505 }
  1         3  
  1         5  
36              
37             sub can_mutate_explicitely_mutable_reference : Test(1)
38             {
39 1     1 0 197 my ($self) = @_;
40              
41 1         8 $self->{accessor}->mutable(1);
42 1         5 $self->{accessor}->value('baz');
43 1         5 $self->{accessor}->value()->[1] = 'bar';
44 1 50       4 is(scalar(@{ $self->{accessor}->value() }), 2, 'cannot mutate instance reference' ) || diag(Dumper($self->{accessor}->value()));
  1         4  
45 1     1   408 }
  1         2  
  1         7  
46              
47             }
48             1;
49             =head1 NAME
50              
51             =head1 VERSION
52              
53             =head1 SYNOPSIS
54              
55             =head1 METHODS
56              
57             =head1 AUTHOR
58              
59             Jamie Beverly, C<< >>
60              
61             =head1 BUGS
62              
63             Please report any bugs or feature requests to C,
64             or through
65             the web interface at
66             L. I will be
67             notified, and then you'll
68             automatically be notified of progress on your bug as I make changes.
69              
70             =head1 SUPPORT
71              
72             You can find documentation for this module with the perldoc command.
73              
74             perldoc OOP::Perlish::Class
75              
76              
77             You can also look for information at:
78              
79             =over 4
80              
81             =item * RT: CPAN's request tracker
82              
83             L
84              
85             =item * AnnoCPAN: Annotated CPAN documentation
86              
87             L
88              
89             =item * CPAN Ratings
90              
91             L
92              
93             =item * Search CPAN
94              
95             L
96              
97             =back
98              
99              
100             =head1 ACKNOWLEDGEMENTS
101              
102             =head1 COPYRIGHT & LICENSE
103              
104             Copyright 2009 Jamie Beverly
105              
106             This program is free software; you can redistribute it and/or modify it
107             under the terms of either: the GNU General Public License as published
108             by the Free Software Foundation; or the Artistic License.
109              
110             See http://dev.perl.org/licenses/ for more information.
111              
112             =cut