File Coverage

blib/lib/OOP/Perlish/Class/UnitTests/Base.pm
Criterion Covered Total %
statement 206 207 99.5
branch 1 2 50.0
condition n/a
subroutine 76 76 100.0
pod n/a
total 283 285 99.3


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2 1     1   5 use warnings;
  1         2  
  1         39  
3 1     1   6 use strict;
  1         2  
  1         55  
4             {
5             package OOP::Perlish::Class::UnitTests::Base;
6 1     1   6 use warnings;
  1         3  
  1         26  
7 1     1   5 use strict;
  1         2  
  1         27  
8 1     1   5 use Test::Class;
  1         2  
  1         19  
9 1     1   6 use Test::More;
  1         1  
  1         12  
10 1     1   320 use base qw(Test::Class);
  1         2  
  1         129  
11             }
12              
13             {
14             package OOP::Perlish::Class::UnitTests::Foo;
15 1     1   7 use warnings;
  1         2  
  1         25  
16 1     1   6 use strict;
  1         2  
  1         30  
17 1     1   5 use OOP::Perlish::Class;
  1         1  
  1         9  
18 1     1   6 use base qw(OOP::Perlish::Class);
  1         2  
  1         120  
19              
20             BEGIN {
21 1     1   14 __PACKAGE__->_accessors(
22             foo => {
23             type => 'SCALAR',
24             validator => qr/.*foo.*/,
25             },
26             );
27             };
28             }
29              
30             {
31             package OOP::Perlish::Class::UnitTests::Bar;
32 1     1   10 use warnings;
  1         2  
  1         48  
33 1     1   12 use strict;
  1         1  
  1         34  
34 1     1   5 use OOP::Perlish::Class;
  1         1  
  1         5  
35 1     1   10 use base qw(OOP::Perlish::Class);
  1         2  
  1         127  
36              
37             BEGIN {
38 1     1   18 __PACKAGE__->_accessors(
39             foo => {
40             type => 'SCALAR',
41             validator => qr/.*ralph.*/i,
42             },
43             );
44             };
45             }
46             {
47             package OOP::Perlish::Class::UnitTests::Bar::Bar;
48 1     1   7 use warnings;
  1         2  
  1         38  
49 1     1   5 use strict;
  1         2  
  1         38  
50 1     1   5 use base 'OOP::Perlish::Class::UnitTests::Bar';
  1         1  
  1         713  
51              
52             BEGIN {
53 1     1   24 __PACKAGE__->_accessors(
54             bar => {
55             type => 'HASHREF',
56             validator => qr/.*bar.*/,
57             },
58             );
59             };
60             }
61             {
62             package OOP::Perlish::Class::UnitTests::Baz;
63 1     1   5 use warnings;
  1         1  
  1         23  
64 1     1   4 use strict;
  1         2  
  1         27  
65 1     1   4 use base qw(OOP::Perlish::Class);
  1         1  
  1         87  
66              
67             BEGIN {
68 1     1   9 __PACKAGE__->_accessors(
69             baz => {
70             type => 'SCALAR',
71             validator => qr/.*baz.*/,
72             },
73             );
74             };
75             }
76              
77             {
78             package OOP::Perlish::Class::UnitTests::Baz::Foo::Bar;
79 1     1   5 use warnings;
  1         1  
  1         27  
80 1     1   4 use strict;
  1         1  
  1         24  
81 1     1   3 use base qw( OOP::Perlish::Class::UnitTests::Foo OOP::Perlish::Class::UnitTests::Baz );
  1         2  
  1         1081  
82              
83             BEGIN {
84             __PACKAGE__->_accessors(
85             bar => {
86             type => 'SCALAR',
87             validator => sub {
88 20         28 my $self = shift;
89 20         25 my $val = shift;
90            
91 20         24 my $bazval = $val;
92 20 50       90 $bazval =~ s/bar/baz/ && do {
93 20         94 $self->baz($bazval);
94 20         104 return $val;
95             };
96             return
97 0         0 },
98 1     1   40 required => 1,
99             },
100             )
101             };
102             }
103              
104             {
105             package OOP::Perlish::Class::UnitTests::Baz::Foo::Bar::Overload;
106 1     1   5 use warnings;
  1         2  
  1         31  
107 1     1   4 use strict;
  1         2  
  1         35  
108 1     1   5 use base qw(OOP::Perlish::Class::UnitTests::Baz::Foo::Bar);
  1         1  
  1         609  
109              
110             BEGIN {
111 1     1   15 __PACKAGE__->_accessors(
112             bar => {
113             type => 'SCALAR',
114             validator => qr/.*overloaded.*/,
115             },
116             );
117             };
118             }
119              
120             {
121             package OOP::Perlish::Class::UnitTests::Fred;
122 1     1   6 use warnings;
  1         2  
  1         21  
123 1     1   5 use strict;
  1         1  
  1         25  
124 1     1   835 use IO::File;
  1         2231  
  1         139  
125 1     1   4 use base qw(OOP::Perlish::Class File::Find);
  1         2  
  1         119  
126              
127             BEGIN {
128 1     1   11 __PACKAGE__->_accessors(
129             bar => {
130             type => 'SCALAR',
131             validator => qr/.*set.*/,
132             },
133             );
134             };
135             }
136              
137             {
138             package OOP::Perlish::Class::UnitTests::TestRequired;
139 1     1   9 use warnings;
  1         2  
  1         40  
140 1     1   6 use strict;
  1         2  
  1         41  
141 1     1   6 use base qw(OOP::Perlish::Class);
  1         2  
  1         115  
142              
143             BEGIN {
144 1     1   11 __PACKAGE__->_accessors(
145             fud => {
146             required => 1,
147             type => 'SCALAR',
148             },
149             );
150             };
151             }
152              
153             {
154             package OOP::Perlish::Class::UnitTests::TestAccessorOverloadingWithMethod;
155 1     1   7 use warnings;
  1         2  
  1         28  
156 1     1   6 use strict;
  1         1  
  1         38  
157              
158 1     1   4 use base qw(OOP::Perlish::Class::UnitTests::TestRequired);
  1         2  
  1         819  
159              
160             sub fud
161             {
162 3     3   5 my ($self) = @_;
163 3         12 return 'method, not accessor';
164             }
165             }
166              
167              
168              
169             {
170             package OOP::Perlish::Class::UnitTests::TestValidDefaults;
171 1     1   7 use warnings;
  1         2  
  1         30  
172 1     1   5 use strict;
  1         3  
  1         44  
173 1     1   5 use base qw(OOP::Perlish::Class);
  1         2  
  1         72  
174 1     1   5 use IO::File;
  1         2  
  1         402  
175              
176             BEGIN {
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         6 default => sub { return('test') },
196             },
197 1     1   23 'object' => {
198             type => 'OBJECT',
199             object_can => [ 'open' ],
200             default => IO::File->new(),
201             },
202             );
203             };
204             }
205            
206             {
207             package OOP::Perlish::Class::UnitTests::TestInvalidDefaultScalar;
208 1     1   15 use warnings;
  1         2  
  1         55  
209 1     1   6 use strict;
  1         2  
  1         45  
210 1     1   6 use base qw(OOP::Perlish::Class);
  1         4  
  1         128  
211 1     1   7 use IO::File;
  1         2  
  1         310  
212              
213             BEGIN {
214 1     1   18 __PACKAGE__->_accessors(
215             'scalar' => {
216             type => 'SCALAR',
217             validator => qr/test/,
218             default => 'invalid',
219             },
220             );
221             }
222             }
223             {
224             package OOP::Perlish::Class::UnitTests::TestInvalidDefaultArray;
225 1     1   6 use warnings;
  1         4  
  1         38  
226 1     1   5 use strict;
  1         2  
  1         30  
227 1     1   4 use base qw(OOP::Perlish::Class);
  1         2  
  1         96  
228 1     1   5 use IO::File;
  1         2  
  1         223  
229              
230             BEGIN {
231 1     1   13 __PACKAGE__->_accessors(
232             'array' => {
233             type => 'ARRAY',
234             validator => qr/test/,
235             default => [ 'invalid' ],
236             },
237             );
238             };
239             }
240             {
241             package OOP::Perlish::Class::UnitTests::TestInvalidDefaultHash;
242 1     1   7 use warnings;
  1         3  
  1         48  
243 1     1   5 use strict;
  1         2  
  1         33  
244 1     1   5 use base qw(OOP::Perlish::Class);
  1         2  
  1         95  
245 1     1   6 use IO::File;
  1         2  
  1         224  
246              
247             BEGIN {
248 1     1   15 __PACKAGE__->_accessors(
249             'hash' => {
250             type => 'HASH',
251             validator => qr/test/,
252             default => { asdf => 'invalid' },
253             },
254             );
255             };
256             }
257             {
258             package OOP::Perlish::Class::UnitTests::TestInvalidDefaultCode;
259 1     1   11 use warnings;
  1         20  
  1         38  
260 1     1   6 use strict;
  1         2  
  1         46  
261 1     1   5 use base qw(OOP::Perlish::Class);
  1         2  
  1         113  
262 1     1   7 use IO::File;
  1         3  
  1         231  
263              
264             BEGIN {
265 1     1   21 __PACKAGE__->_accessors(
266             'code' => {
267             type => 'CODE',
268             default => 'invalid',
269             },
270             );
271             };
272             }
273             {
274             package OOP::Perlish::Class::UnitTests::TestInvalidDefaultObject;
275 1     1   7 use warnings;
  1         2  
  1         40  
276 1     1   5 use strict;
  1         2  
  1         39  
277 1     1   5 use base qw(OOP::Perlish::Class);
  1         2  
  1         76  
278 1     1   4 use IO::File;
  1         2  
  1         218  
279              
280             BEGIN {
281 1     1   16 __PACKAGE__->_accessors(
282             'object' => {
283             type => 'OBJECT',
284             object_can => [ 'invalid_method_name' ],
285             default => IO::File->new(),
286             },
287             );
288             };
289             }
290             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<< >>
304              
305             =head1 BUGS
306              
307             Please report any bugs or feature requests to C,
308             or through
309             the web interface at
310             L. 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
328              
329             =item * AnnoCPAN: Annotated CPAN documentation
330              
331             L
332              
333             =item * CPAN Ratings
334              
335             L
336              
337             =item * Search CPAN
338              
339             L
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