Class/UnitTests/Base.pm

filter: Statementstmt 99.5% 223 / 224 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 78 / 78 Podpod n/a totaltotal 99.3% 302 / 304 CC 2 SCAR 0.3
CC
2
Cov
99%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Class/Abstract/UnitTests/Interfaces.pm ↑ Summary Class/UnitTests/TestEmit.pm »
1 #!/usr/bin/perl
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 {
5 package OOP::Perlish::Class::UnitTests::Base;
6 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ use Test::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶ use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶ use base qw(Test::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 }
12  
13 {
14 1 package OOP::Perlish::Class::UnitTests::Foo;
15 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use OOP::Perlish::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 __PACKAGE__->_accessors(
22 foo => {
23 type => 'SCALAR',
24 validator => qr/.*foo.*/,
25 },
26 );
27 };
28 }
29  
30 {
31 1 package OOP::Perlish::Class::UnitTests::Bar;
32 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶ use OOP::Perlish::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 __PACKAGE__->_accessors(
39 foo => {
40 type => 'SCALAR',
41 validator => qr/.*ralph.*/i,
42 },
43 );
44 };
45 }
46 {
47 1 package OOP::Perlish::Class::UnitTests::Bar::Bar;
48 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 1 ▶ use base 'OOP::Perlish::Class::UnitTests::Bar';
Subroutine BEGIN: called CC=1 SCAR=0.0
51  
52 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 __PACKAGE__->_accessors(
54 bar => {
55 type => 'HASHREF',
56 validator => qr/.*bar.*/,
57 },
58 );
59 };
60 }
61 {
62 1 package OOP::Perlish::Class::UnitTests::Baz;
63 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
68 1 __PACKAGE__->_accessors(
69 baz => {
70 type => 'SCALAR',
71 validator => qr/.*baz.*/,
72 },
73 );
74 };
75 }
76  
77 {
78 1 package OOP::Perlish::Class::UnitTests::Baz::Foo::Bar;
79 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
81 1 ▶ use base qw( OOP::Perlish::Class::UnitTests::Foo OOP::Perlish::Class::UnitTests::Baz );
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.1
84 __PACKAGE__->_accessors(
85 bar => {
86 type => 'SCALAR',
87 20 ▶ validator => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
88 20 my $self = shift;
89 20 my $val = shift;
90
91 20 my $bazval = $val;
92 20 ▶ $bazval =~ s/bar/baz/ && do {
Branch: 1 branch
BranchTrueFalseTotal
$bazval =~ s/bar/baz/ and do { $self->baz($bazval); return $val } 20 0 20
93 20 $self->baz($bazval);
94 20 return $val;
95 };
96 return
97 0 },
98 1 required => 1,
99 },
100 )
101 };
102 }
103  
104 {
105 1 package OOP::Perlish::Class::UnitTests::Baz::Foo::Bar::Overload;
106 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 1 ▶ use base qw(OOP::Perlish::Class::UnitTests::Baz::Foo::Bar);
Subroutine BEGIN: called CC=1 SCAR=0.0
109  
110 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
111 1 __PACKAGE__->_accessors(
112 bar => {
113 type => 'SCALAR',
114 validator => qr/.*overloaded.*/,
115 },
116 );
117 };
118 }
119  
120 {
121 1 package OOP::Perlish::Class::UnitTests::Fred;
122 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
123 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
124 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
125 1 ▶ use base qw(OOP::Perlish::Class File::Find);
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
128 1 __PACKAGE__->_accessors(
129 bar => {
130 type => 'SCALAR',
131 validator => qr/.*set.*/,
132 },
133 );
134 };
135 }
136  
137 {
138 1 package OOP::Perlish::Class::UnitTests::TestRequired;
139 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
140 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
141 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
142  
143 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
144 1 __PACKAGE__->_accessors(
145 fud => {
146 required => 1,
147 type => 'SCALAR',
148 },
149 );
150 };
151 }
152  
153 {
154 1 package OOP::Perlish::Class::UnitTests::TestAccessorOverloadingWithMethod;
155 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
156 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
157  
158 1 ▶ use base qw(OOP::Perlish::Class::UnitTests::TestRequired);
Subroutine BEGIN: called CC=1 SCAR=0.0
159  
160 sub fud
161 3 ▶ {
Subroutine fud: called CC=1 SCAR=0.0
162 3 my ($self) = @_;
163 3 return 'method, not accessor';
164 }
165 }
166  
167  
168  
169 {
170 1 package OOP::Perlish::Class::UnitTests::TestValidDefaults;
171 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
172 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
173 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
174 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
175  
176 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
177 __PACKAGE__->_accessors(
178 'scalar' => {
179 type => 'SCALAR',
180 validator => qr/test/,
181 default => 'test',
182 },
183 'array' => {
184 type => 'ARRAY',
185 validator => qr/test/,
186 default => [ 'test' ],
187 },
188 'hash' => {
189 type => 'HASH',
190 validator => qr/test/,
191 default => { key => 'test' },
192 },
193 'code' => {
194 type => 'CODE',
195 1 ▶ default => sub { return('test') },
Subroutine __ANON__: called CC=1 SCAR=0.0
196 },
197 1 'object' => {
198 type => 'OBJECT',
199 object_can => [ 'open' ],
200 default => IO::File->new(),
201 },
202 );
203 };
204 }
205
206 {
207 1 package OOP::Perlish::Class::UnitTests::TestInvalidDefaultScalar;
208 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
209 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
210 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
211 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
212  
213 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
214 1 __PACKAGE__->_accessors(
215 'scalar' => {
216 type => 'SCALAR',
217 validator => qr/test/,
218 default => 'invalid',
219 },
220 );
221 }
222 }
223 {
224 1 package OOP::Perlish::Class::UnitTests::TestInvalidDefaultArray;
225 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
226 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
227 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
228 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
229  
230 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
231 1 __PACKAGE__->_accessors(
232 'array' => {
233 type => 'ARRAY',
234 validator => qr/test/,
235 default => [ 'invalid' ],
236 },
237 );
238 };
239 }
240 {
241 1 package OOP::Perlish::Class::UnitTests::TestInvalidDefaultHash;
242 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
243 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
244 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
245 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
246  
247 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
248 1 __PACKAGE__->_accessors(
249 'hash' => {
250 type => 'HASH',
251 validator => qr/test/,
252 default => { asdf => 'invalid' },
253 },
254 );
255 };
256 }
257 {
258 1 package OOP::Perlish::Class::UnitTests::TestInvalidDefaultCode;
259 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
260 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
261 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
262 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
263  
264 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
265 1 __PACKAGE__->_accessors(
266 'code' => {
267 type => 'CODE',
268 default => 'invalid',
269 },
270 );
271 };
272 }
273 {
274 1 package OOP::Perlish::Class::UnitTests::TestInvalidDefaultObject;
275 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
276 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
277 1 ▶ use base qw(OOP::Perlish::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
278 1 ▶ use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
279  
280 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
281 1 __PACKAGE__->_accessors(
282 'object' => {
283 type => 'OBJECT',
284 object_can => [ 'invalid_method_name' ],
285 default => IO::File->new(),
286 },
287 );
288 };
289 }
290 1 1;
291  
292  
293 =head1 NAME
294  
295 =head1 VERSION
296  
297 =head1 SYNOPSIS
298  
299 =head1 METHODS
300  
301 =head1 AUTHOR
302  
303 Jamie Beverly, C<< <jbeverly at cpan.org> >>
304  
305 =head1 BUGS
306  
307 Please report any bugs or feature requests to C<bug-foo-bar at rt.cpan.org>,
308 or through
309 the web interface at
310 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=OOP-Perlish-Class>. I will be
311 notified, and then you'll
312 automatically be notified of progress on your bug as I make changes.
313  
314 =head1 SUPPORT
315  
316 You can find documentation for this module with the perldoc command.
317  
318 perldoc OOP::Perlish::Class
319  
320  
321 You can also look for information at:
322  
323 =over 4
324  
325 =item * RT: CPAN's request tracker
326  
327 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=OOP-Perlish-Class>
328  
329 =item * AnnoCPAN: Annotated CPAN documentation
330  
331 L<http://annocpan.org/dist/OOP-Perlish-Class>
332  
333 =item * CPAN Ratings
334  
335 L<http://cpanratings.perl.org/d/OOP-Perlish-Class>
336  
337 =item * Search CPAN
338  
339 L<http://search.cpan.org/dist/OOP-Perlish-Class/>
340  
341 =back
342  
343  
344 =head1 ACKNOWLEDGEMENTS
345  
346 =head1 COPYRIGHT & LICENSE
347  
348 Copyright 2009 Jamie Beverly
349  
350 This program is free software; you can redistribute it and/or modify it
351 under the terms of either: the GNU General Public License as published
352 by the Free Software Foundation; or the Artistic License.
353  
354 See http://dev.perl.org/licenses/ for more information.
355  
356 =cut
« Class/Abstract/UnitTests/Interfaces.pm ↑ Summary Class/UnitTests/TestEmit.pm »