Class/Accessor/UnitTests/Code.pm

filter: Statementstmt 98.0% 50 / 51 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.1% 16 / 17 Podpod 0.0% 0 / 5 totaltotal 89.3% 67 / 75 CC 2 SCAR 1.2
CC
2
Cov
96%
unset_value
2.0
__ANON__
1.1
set_value
1.0
CRAP 1.1
« Class/Accessor/UnitTests/Scalar.pm ↑ Summary Class/Singleton/UnitTests/Singleton.pm »
1 {
2 package OOP::Perlish::Class::Accessor::UnitTests::Code;
3 1 ▶ use OOP::Perlish::Class::Accessor::UnitTests::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ use base qw(OOP::Perlish::Class::Accessor::UnitTests::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶ use OOP::Perlish::Class::Accessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶ use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶ sub setup : Test(setup)
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
10 {
11 4 my ($self) = @_;
12 4 $self->{accessor} = OOP::Perlish::Class::Accessor->new( type => 'CODE', name => 'test', self => bless({}, __PACKAGE__) );
13 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶ sub set_value : Test
Subroutine set_value: called CC=1 SCAR=0.1
Pod undocumented
16 {
17 1 my ($self) = @_;
18 0 ▶ my $coderef = sub { return; };
Subroutine __ANON__: not called CC=1 SCAR=1.2
19  
20 1 $self->{accessor}->value( $coderef );
21 1 is( $self->{accessor}->value(), $coderef, 'can set coderef' );
22 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶ sub negative_set_value : Test
Subroutine negative_set_value: called CC=1 SCAR=0.0
Pod undocumented
25 {
26 1 my ($self) = @_;
27  
28 1 my $coderef = 'foo';
29  
30 1 $self->{accessor}->value( $coderef );
31 1 ok( ! $self->{accessor}->value(), 'negative assert: cannot set non-coderef' );
32 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 1 ▶ sub returned_coderef_executable : Test
Subroutine returned_coderef_executable: called CC=1 SCAR=0.0
Pod undocumented
35 {
36 1 my ($self) = @_;
37  
38 1 ▶ my $coderef = sub { return 'Foo'; };
Subroutine __ANON__: called CC=1 SCAR=0.0
39  
40 1 $self->{accessor}->value( $coderef );
41 1 is( $self->{accessor}->value()->(), 'Foo', 'can set coderef' );
42 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 1 ▶ sub unset_value : Test
Subroutine unset_value: called CC=2 SCAR=7.1
Pod undocumented
45 {
46 1 my ($self) = @_;
47 1 my $undef = $self->{accessor}->value();
48 1 ▶ ok( ! $undef, 'when nothing has been defined, we get undef for scalar' ) || diag(Dumper($undef));
Branch: 1 branch
BranchTrueFalseTotal
&ok(!$undef, "when nothing has been defined, we get undef for scalar") or diag(Dumper($undef)) 1 0 1
49 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
50 }
51 1 1;
52 =head1 NAME
53  
54 =head1 VERSION
55  
56 =head1 SYNOPSIS
57  
58 =head1 METHODS
59  
60 =head1 AUTHOR
61  
62 Jamie Beverly, C<< <jbeverly at cpan.org> >>
63  
64 =head1 BUGS
65  
66 Please report any bugs or feature requests to C<bug-foo-bar at rt.cpan.org>,
67 or through
68 the web interface at
69 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=OOP-Perlish-Class>. I will be
70 notified, and then you'll
71 automatically be notified of progress on your bug as I make changes.
72  
73 =head1 SUPPORT
74  
75 You can find documentation for this module with the perldoc command.
76  
77 perldoc OOP::Perlish::Class
78  
79  
80 You can also look for information at:
81  
82 =over 4
83  
84 =item * RT: CPAN's request tracker
85  
86 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=OOP-Perlish-Class>
87  
88 =item * AnnoCPAN: Annotated CPAN documentation
89  
90 L<http://annocpan.org/dist/OOP-Perlish-Class>
91  
92 =item * CPAN Ratings
93  
94 L<http://cpanratings.perl.org/d/OOP-Perlish-Class>
95  
96 =item * Search CPAN
97  
98 L<http://search.cpan.org/dist/OOP-Perlish-Class/>
99  
100 =back
101  
102  
103 =head1 ACKNOWLEDGEMENTS
104  
105 =head1 COPYRIGHT & LICENSE
106  
107 Copyright 2009 Jamie Beverly
108  
109 This program is free software; you can redistribute it and/or modify it
110 under the terms of either: the GNU General Public License as published
111 by the Free Software Foundation; or the Artistic License.
112  
113 See http://dev.perl.org/licenses/ for more information.
114  
115 =cut
« Class/Accessor/UnitTests/Scalar.pm ↑ Summary Class/Singleton/UnitTests/Singleton.pm »