| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
{ |
|
2
|
|
|
|
|
|
|
package OOP::Perlish::Class::Accessor::UnitTests::Object; |
|
3
|
1
|
|
|
1
|
|
8
|
use OOP::Perlish::Class::Accessor::UnitTests::Base; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use base qw(OOP::Perlish::Class::Accessor::UnitTests::Base); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
101
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use OOP::Perlish::Class::Accessor; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Test::More; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
7
|
1
|
|
|
1
|
|
320
|
use IO::Handle; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
41
|
|
|
8
|
1
|
|
|
1
|
|
1443
|
use Getopt::Long; |
|
|
1
|
|
|
|
|
14643
|
|
|
|
1
|
|
|
|
|
8
|
|
|
9
|
1
|
|
|
1
|
|
1700
|
use File::Temp; |
|
|
1
|
|
|
|
|
17362
|
|
|
|
1
|
|
|
|
|
242
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub setup : Test(setup) |
|
12
|
|
|
|
|
|
|
{ |
|
13
|
13
|
|
|
13
|
0
|
5529
|
my ($self) = @_; |
|
14
|
13
|
|
|
|
|
136
|
$self->{accessor} = OOP::Perlish::Class::Accessor->new( type => 'OBJECT', name => 'test', self => bless({}, __PACKAGE__) ); |
|
15
|
1
|
|
|
1
|
|
13
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set_object : Test |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
1
|
|
|
1
|
0
|
142
|
my ($self) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
7
|
my $obj = IO::Handle->new(); |
|
22
|
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
27
|
$self->{accessor}->value($obj); |
|
24
|
1
|
|
|
|
|
7
|
is($self->{accessor}->value(), $obj, 'can set an object'); |
|
25
|
1
|
|
|
1
|
|
412
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub negative_assertion_set_object : Test |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
1
|
|
|
1
|
0
|
157
|
my ($self) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
6
|
$self->{accessor}->value('foo'); |
|
32
|
1
|
50
|
|
|
|
6
|
ok( ! $self->{accessor}->value(), 'Negative assertion: cannot set something that is not an object' ) || diag( $self->{accessor}->value() ); |
|
33
|
1
|
|
|
1
|
|
273
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub polymorphism : Test |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
1
|
|
|
1
|
0
|
155
|
my ($self) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
6
|
my $obj = IO::Handle->new(); |
|
40
|
1
|
|
|
|
|
25
|
$self->{accessor}->object_can(['fileno','fdopen','close']); |
|
41
|
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
6
|
$self->{accessor}->value($obj); |
|
43
|
1
|
|
|
|
|
5
|
is($self->{accessor}->value(), $obj, 'can set an object matching object_can'); |
|
44
|
1
|
|
|
1
|
|
309
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub negative_assert_polymorphism : Test |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
1
|
|
|
1
|
0
|
361
|
my ($self) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
9
|
my $obj = Getopt::Long::Parser->new(); |
|
51
|
1
|
|
|
|
|
32
|
$self->{accessor}->object_can(['fileno','fdopen','close']); |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
8
|
$self->{accessor}->value($obj); |
|
54
|
1
|
|
|
|
|
6
|
ok( ! $self->{accessor}->value(), 'Negative assertion: cannot set an object not matching object_can'); |
|
55
|
1
|
|
|
1
|
|
306
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub negative_assert_derived : Test |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
1
|
|
|
1
|
0
|
178
|
my ($self) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
13
|
my $obj = Getopt::Long::Parser->new(); |
|
62
|
1
|
|
|
|
|
37
|
$self->{accessor}->object_isa(['IO::Handle']); |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
9
|
$self->{accessor}->value($obj); |
|
65
|
1
|
|
|
|
|
10
|
ok( ! $self->{accessor}->value(), 'Negative assertion: cannot set an object not matching object_isa'); |
|
66
|
1
|
|
|
1
|
|
301
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub derived : Test |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
1
|
|
|
1
|
0
|
193
|
my ($self) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
15
|
my $obj = File::Temp->new(); |
|
73
|
1
|
|
|
|
|
1497
|
$self->{accessor}->object_isa(['IO::Handle']); |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
8
|
$self->{accessor}->value($obj); |
|
76
|
1
|
|
|
|
|
7
|
is( $self->{accessor}->value(), $obj, 'can set an object not matching object_isa'); |
|
77
|
1
|
|
|
1
|
|
304
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub validator : Test |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
1
|
|
|
1
|
0
|
137
|
my ($self) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
13
|
my $obj = File::Temp->new(); |
|
84
|
1
|
|
|
|
|
586
|
$self->{accessor}->validator(qr/.*Temp.*/); |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
6
|
$self->{accessor}->value($obj); |
|
87
|
1
|
|
|
|
|
8
|
is( $self->{accessor}->value(), $obj, 'can set an object matching regexp'); |
|
88
|
1
|
|
|
1
|
|
418
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
13
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub negative_validator : Test |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
1
|
|
|
1
|
0
|
136
|
my ($self) = @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
9
|
my $obj = IO::Handle->new(); |
|
95
|
1
|
|
|
|
|
36
|
$self->{accessor}->validator(qr/.*Temp.*/); |
|
96
|
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
6
|
$self->{accessor}->value($obj); |
|
98
|
1
|
|
|
|
|
5
|
ok( ! $self->{accessor}->value(), 'Negative assert: cannot set an object not matching regexp'); |
|
99
|
1
|
|
|
1
|
|
305
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub validator_sub : Test |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
1
|
|
|
1
|
0
|
139
|
my ($self) = @_; |
|
104
|
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
9
|
my $obj = File::Temp->new(); |
|
106
|
1
|
50
|
|
2
|
|
447
|
$self->{accessor}->validator(sub { my ($self, $o) = @_; ref($o) =~ m/File::Temp/ && return $o; return }); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
188
|
|
|
|
0
|
|
|
|
|
0
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
6
|
$self->{accessor}->value($obj); |
|
109
|
1
|
|
|
|
|
8
|
is( $self->{accessor}->value(), $obj, 'can set an object matching sub'); |
|
110
|
1
|
|
|
1
|
|
364
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub negative_validator_sub : Test |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
1
|
|
|
1
|
0
|
138
|
my ($self) = @_; |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
6
|
my $obj = IO::Handle->new(); |
|
117
|
1
|
50
|
|
2
|
|
26
|
$self->{accessor}->validator(sub { my ($self, $o) = @_; ref($o) =~ m/File::Temp/ && return $o; return }); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
9
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
1
|
|
|
|
|
15
|
$self->{accessor}->value($obj); |
|
120
|
1
|
|
|
|
|
5
|
ok( ! $self->{accessor}->value(), 'Negative assert: cannot set an object not matching sub'); |
|
121
|
1
|
|
|
1
|
|
347
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub implementation : Test |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
1
|
|
|
1
|
0
|
168
|
my ($self) = @_; |
|
126
|
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
9
|
$self->{accessor}->implements([ 'IO::Handle' ]); |
|
128
|
|
|
|
|
|
|
|
|
129
|
1
|
|
|
|
|
10
|
my $obj = IO::Handle->new(); |
|
130
|
1
|
|
|
|
|
36
|
$self->{accessor}->value($obj); |
|
131
|
1
|
|
|
|
|
9
|
is($self->{accessor}->value(), $obj, 'can set an object matching implementation'); |
|
132
|
1
|
|
|
1
|
|
313
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
4
|
|
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub negative_assert_implementation : Test |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
1
|
|
|
1
|
0
|
245
|
my ($self) = @_; |
|
137
|
|
|
|
|
|
|
|
|
138
|
1
|
|
|
|
|
9
|
$self->{accessor}->implements(['IO::Handle']); |
|
139
|
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
9
|
my $obj = Getopt::Long::Parser->new(); |
|
141
|
1
|
|
|
|
|
41
|
$self->{accessor}->value($obj); |
|
142
|
1
|
|
|
|
|
13
|
ok( ! $self->{accessor}->value(), 'Negative assertion: cannot set an object not matching implementation'); |
|
143
|
1
|
|
|
1
|
|
361
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub unset_value : Test |
|
146
|
|
|
|
|
|
|
{ |
|
147
|
1
|
|
|
1
|
0
|
136
|
my ($self) = @_; |
|
148
|
1
|
|
|
|
|
5
|
my $undef = $self->{accessor}->value(); |
|
149
|
1
|
50
|
|
|
|
6
|
ok( ! $undef, 'when nothing has been defined, we get undef for scalar' ) || diag(Dumper($undef)); |
|
150
|
1
|
|
|
1
|
|
289
|
} |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
10
|
|
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
1; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 NAME |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 VERSION |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 METHODS |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Jamie Beverly, C<< >> |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 BUGS |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, |
|
171
|
|
|
|
|
|
|
or through |
|
172
|
|
|
|
|
|
|
the web interface at |
|
173
|
|
|
|
|
|
|
L. I will be |
|
174
|
|
|
|
|
|
|
notified, and then you'll |
|
175
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 SUPPORT |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
perldoc OOP::Perlish::Class |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
You can also look for information at: |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=over 4 |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
L |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
L |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
L |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item * Search CPAN |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
L |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=back |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Copyright 2009 Jamie Beverly |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
214
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
215
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |