line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::PObject::Test::ISA; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: ISA.pm,v 1.1.2.2 2004/05/20 06:53:53 sherzodr Exp $ |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1553
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
110
|
|
6
|
|
|
|
|
|
|
#use diagnostics; |
7
|
3
|
|
|
3
|
|
2083
|
use Test::More tests => 19; |
|
3
|
|
|
|
|
56296
|
|
|
3
|
|
|
|
|
31
|
|
8
|
3
|
|
|
3
|
|
4593
|
use Class::PObject; |
|
3
|
|
|
|
|
49
|
|
|
3
|
|
|
|
|
20
|
|
9
|
3
|
|
|
3
|
|
2131
|
use Data::Dumper; |
|
3
|
|
|
|
|
22956
|
|
|
3
|
|
|
|
|
314
|
|
10
|
|
|
|
|
|
|
require Class::PObject::Test; |
11
|
3
|
|
|
3
|
|
26
|
use vars ('$VERSION', '@ISA'); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1464
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@ISA = ('Class::PObject::Test'); |
14
|
|
|
|
|
|
|
$VERSION = '1.01'; |
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
331
|
use_ok("Class::PObject"); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
14
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub run { |
20
|
3
|
|
|
3
|
0
|
18
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
|
|
0
|
package PO::Parent; |
24
|
|
|
|
|
|
|
Class::PObject::pobject { |
25
|
|
|
|
|
|
|
columns => ['id', 'data'], |
26
|
|
|
|
|
|
|
driver => $self->{driver}, |
27
|
|
|
|
|
|
|
datasource => $self->{datasource} |
28
|
3
|
|
|
|
|
42
|
}; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
3
|
|
10
|
sub is_parent { 1 } |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
{ |
34
|
3
|
|
|
|
|
3
|
package PO::Child; |
|
0
|
|
|
|
|
0
|
|
35
|
3
|
|
|
|
|
35
|
@PO::Child::ISA = ("PO::Parent"); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# sub __props { |
38
|
|
|
|
|
|
|
# return $PO::Parent::props; |
39
|
|
|
|
|
|
|
# } |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
3
|
|
13
|
sub is_child { 1 } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
7
|
my $child = PO::Child->new(); |
|
3
|
|
|
|
|
26
|
|
47
|
3
|
|
|
|
|
20
|
ok(defined $child); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# let's check the inheritance tree |
50
|
3
|
|
|
|
|
1899
|
ok($child->UNIVERSAL::isa("PO::Child")); |
51
|
3
|
|
|
|
|
937
|
ok($child->UNIVERSAL::isa("PO::Parent")); |
52
|
3
|
|
|
|
|
958
|
ok($child->UNIVERSAL::isa("Class::PObject::Template")); |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
959
|
ok($child->is_child == 1); |
55
|
3
|
|
|
|
|
967
|
ok($child->is_parent == 1); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# PO::Child should also have access to PO::Parent->id() and PO::Parent->data() |
58
|
|
|
|
|
|
|
# methods |
59
|
3
|
|
|
|
|
968
|
ok($child->UNIVERSAL::can("id")); |
60
|
3
|
|
|
|
|
941
|
ok($child->UNIVERSAL::can("data")); |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
964
|
$child->data("check"); |
63
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
12
|
ok($child->data() eq "check"); |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
1019
|
my $new_id = $child->save(); |
67
|
1
|
|
|
|
|
7
|
ok($new_id); |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
784
|
$child = undef; |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
43
|
ok(PO::Child->count == 1); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# now we're loading previously stored object |
75
|
|
|
|
|
|
|
# |
76
|
1
|
|
|
|
|
754
|
my $child_1 = PO::Child->load( $new_id ); |
77
|
1
|
|
|
|
|
4
|
ok(defined $child_1); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
461
|
ok($child_1->id == $new_id); |
80
|
1
|
|
|
|
|
413
|
ok($child_1->data eq 'check'); |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
416
|
ok($child_1->UNIVERSAL::isa("PO::Child")); |
83
|
1
|
|
|
|
|
419
|
ok($child_1->UNIVERSAL::isa("PO::Parent")); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# |
86
|
|
|
|
|
|
|
# removing all the data |
87
|
|
|
|
|
|
|
# |
88
|
1
|
|
|
|
|
388
|
ok(PO::Child->remove_all); |
89
|
1
|
|
|
|
|
592
|
ok(PO::Child->count() == 0); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
__END__ |