File Coverage

blib/lib/OOP/Perlish/Class/Accessor/UnitTests/HashRef.pm
Criterion Covered Total %
statement 50 50 100.0
branch 3 6 50.0
condition n/a
subroutine 16 16 100.0
pod 0 4 0.0
total 69 76 90.7


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2 1     1   7 use warnings;
  1         3  
  1         43  
3 1     1   7 use strict;
  1         3  
  1         63  
4             {
5              
6             package OOP::Perlish::Class::Accessor::UnitTests::HashRef;
7 1     1   17 use warnings;
  1         4  
  1         36  
8 1     1   7 use strict;
  1         2  
  1         29  
9 1     1   6 use OOP::Perlish::Class::Accessor::UnitTests::Hash;
  1         2  
  1         45  
10 1     1   6 use base 'OOP::Perlish::Class::Accessor::UnitTests::Hash';
  1         2  
  1         115  
11 1     1   7 use OOP::Perlish::Class::Accessor;
  1         2  
  1         11  
12 1     1   7 use Test::More;
  1         2  
  1         29  
13 1     1   407 use Data::Dumper;
  1         4  
  1         144  
14              
15             sub setup : Test(setup)
16             {
17 8     8 0 6472 my ($self) = @_;
18 8         184 $self->{accessor} = OOP::Perlish::Class::Accessor->new( type => 'HASHREF', name => 'test', self => bless( {}, __PACKAGE__ ) );
19 1     1   6 }
  1         1  
  1         21  
20              
21             sub get_value
22             {
23 8     8 0 23 my ($self) = @_;
24              
25 8 50       43 return( %{ $self->{accessor}->value() } ) if(ref($self->{accessor}->value()) eq 'HASH');
  8         37  
26             }
27              
28             sub cannot_mutate_reference : Test(1)
29             {
30 1     1 0 141 my ($self) = @_;
31              
32 1         6 $self->{accessor}->value(baz => 'quux');
33 1         5 $self->{accessor}->value()->{foo} = 'bar';
34 1 50       10 ok( ! exists($self->{accessor}->value()->{foo}), 'cannot mutate instance reference' ) || diag(Dumper($self->{accessor}->value()));
35 1     1   416 }
  1         3  
  1         5  
36              
37             sub can_mutate_explicitely_mutable_reference : Test(1)
38             {
39 1     1 0 188 my ($self) = @_;
40              
41 1         7 $self->{accessor}->mutable(1);
42 1         6 $self->{accessor}->value(baz => 'quux');
43 1         7 $self->{accessor}->value()->{foo} = 'bar';
44 1 50       8 ok( exists($self->{accessor}->value()->{foo}), 'can mutate mutable instance reference' ) || diag(Dumper($self->{accessor}->value()));
45 1     1   338 }
  1         2  
  1         5  
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