classes/Test.pm

filter: Statementstmt 82.3% 42 / 51 Branchbran n/a Conditioncond 24.4% 24 / 98 MC/DCmcdc 0.0% 0 / 58 Subroutinesub 82.3% 14 / 17 Podpod 100% 9 / 9 totaltotal 38.2% 89 / 233 CC 34 SCAR 24.0
CC
34
Cov
44%
is_throwable
22.4
can_set_get
20.0
is_classes_exc
13.3
CRAP 11.1
« classes.pm ↑ Summary
1 package classes::Test;
2  
3 # $Id: Test.pm 147 2008-03-08 16:04:33Z rmuhle $
4  
5 # these two are just really brain dead
6 # when using more advanced perl stuff
7 5 ▶no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 our @EXPORT_OK = qw(
14 can_new
15 can_set_get
16 has_decl
17 has_class_const
18 has_mixins
19 has_mixins_hash
20 is_classes
21 is_throwable
22 is_classes_exc
23 has_tree
24 );
25  
26 5 our %EXPORT_TAGS = ( 'all' => [qw(
27 can_new
28 can_set_get
29 has_decl
30 has_class_const
31 has_mixins
32 has_mixins_hash
33 is_classes
34 is_throwable
35 is_classes_exc
36 )]);
37  
38 5 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 5 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 5 my $t = Test::Builder->new();
41  
42 13 ▶sub can_new (*) {
Subroutine can_new: called CC=3 SCAR=14.2
Pod documented
43 13 ▶ my $this = blessed $_[0] || $_[0];
Condition33%1/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
0130
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table33%1/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
44 13 ▶ return $t->ok(
Condition33%1/3
$t->ok($this->can('new'), "'${this}' has new constructor method") || $t->diag(" '${this}' missing new constructor")
l!l&&r!l&&!r
1300
MC/DC0%0/2
$t->ok($this->can('new'), "'${this}' has new constructor method") || $t->diag(" '${this}' missing new constructor")
$t->ok($this->can('new'), "'${this}' has new constructor method") $t->diag(" '${this}' missing new constructor")
Truth table33%1/3
A || B
A= $t->ok($this->can('new'), "'${this}' has new constructor method")B= $t->diag(" '${this}' missing new constructor")
ABresult
1X1
011
000
45 $this->can('new'),
46 "'$this' has new constructor method"
47 ) ||
48 $t->diag(
49 " '$this' missing new constructor"
50 );
51 }
52  
53 0 ▶sub can_set_get (*) {
Subroutine can_set_get: not called CC=4 SCAR=30.0
Pod documented
54 0 ▶ my $this = blessed $_[0] || $_[0];
Condition0%0/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table0%0/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
55 0 ▶ return $t->ok(
Condition0%0/6
$t->ok($this->can('set') && $this->can('get'), "'${this}' can set, get") || $t->diag(" '${this}' missing set, get")
l!l&&r!l&&!r
000
$this->can('set') && $this->can('get')
!ll&&!rl&&r
000
MC/DC0%0/2
$t->ok($this->can('set') && $this->can('get'), "'${this}' can set, get") || $t->diag(" '${this}' missing set, get")
$t->ok($this->can('set') && $this->can('get'), "'${this}' can set, get") $t->diag(" '${this}' missing set, get")
MC/DC0%0/2
$this->can('set') && $this->can('get')
$this->can('set') $this->can('get')
Truth table0%0/3
A || B
A= $t->ok($this->can('set') && $this->can('get'), "'${this}' can set, get")B= $t->diag(" '${this}' missing set, get")
ABresult
1X1
011
000
Truth table0%0/3
A && B
A= $this->can('set')B= $this->can('get')
ABresult
0X0
100
111
56 $this->can('set')
57 && $this->can('get')
58 , "'$this' can set, get"
59 ) ||
60 $t->diag(" '$this' missing set, get");
61 }
62  
63 # should have a DECL hash ref package variable and method
64 13 ▶sub has_decl (*) {
Subroutine has_decl: called CC=4 SCAR=17.9
Pod documented
65 13 ▶ my $this = blessed $_[0] || $_[0];
Condition33%1/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
0130
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table33%1/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
66 return $t->ok(
67 $this->can('DECL') &&
68 13 ▶ defined ${$this.'::DECL'},
Condition33%2/6
$t->ok($this->can('DECL') && defined ${$this . '::DECL';}, "'${this}' has DECL") || $t->diag(" '${this}' does not have a DECL declaration")
l!l&&r!l&&!r
1300
$this->can('DECL') && defined ${$this . '::DECL';}
!ll&&!rl&&r
0013
MC/DC0%0/2
$t->ok($this->can('DECL') && defined ${$this . '::DECL';}, "'${this}' has DECL") || $t->diag(" '${this}' does not have a DECL declaration")
$t->ok($this->can('DECL') && defined ${$this . '::DECL';}, "'${this}' has DECL") $t->diag(" '${this}' does not have a DECL declaration")
MC/DC0%0/2
$this->can('DECL') && defined ${$this . '::DECL';}
$this->can('DECL') defined ${$this . '::DECL';}
Truth table33%1/3
A || B
A= $t->ok($this->can('DECL') && defined ${$this . '::DECL';}, "'${this}' has DECL")B= $t->diag(" '${this}' does not have a DECL declaration")
ABresult
1X1
011
000
Truth table33%1/3
A && B
A= $this->can('DECL')B= defined ${$this . '::DECL';}
ABresult
0X0
100
111
69 "'$this' has DECL"
70 )
71 || $t->diag(" '$this' does not have a DECL declaration");
72 }
73  
74 13 ▶sub has_class_const (*) {
Subroutine has_class_const: called CC=4 SCAR=17.9
Pod documented
75 13 ▶ my $this = blessed $_[0] || $_[0];
Condition33%1/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
0130
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table33%1/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
76 return $t->ok(
77 $this->can('CLASS') &&
78 13 ▶ defined ${$this.'::CLASS'},
Condition33%2/6
$t->ok($this->can('CLASS') && defined ${$this . '::CLASS';}, "'${this}' has CLASS constant") || $t->diag(" '${this}' does not have a CLASS constant")
l!l&&r!l&&!r
1300
$this->can('CLASS') && defined ${$this . '::CLASS';}
!ll&&!rl&&r
0013
MC/DC0%0/2
$t->ok($this->can('CLASS') && defined ${$this . '::CLASS';}, "'${this}' has CLASS constant") || $t->diag(" '${this}' does not have a CLASS constant")
$t->ok($this->can('CLASS') && defined ${$this . '::CLASS';}, "'${this}' has CLASS constant") $t->diag(" '${this}' does not have a CLASS constant")
MC/DC0%0/2
$this->can('CLASS') && defined ${$this . '::CLASS';}
$this->can('CLASS') defined ${$this . '::CLASS';}
Truth table33%1/3
A || B
A= $t->ok($this->can('CLASS') && defined ${$this . '::CLASS';}, "'${this}' has CLASS constant")B= $t->diag(" '${this}' does not have a CLASS constant")
ABresult
1X1
011
000
Truth table33%1/3
A && B
A= $this->can('CLASS')B= defined ${$this . '::CLASS';}
ABresult
0X0
100
111
79 "'$this' has CLASS constant"
80 )
81 || $t->diag(" '$this' does not have a CLASS constant");
82 }
83  
84 0 ▶sub has_mixins (*) {
Subroutine has_mixins: not called CC=4 SCAR=25.0
Pod documented
85 0 ▶ my $this = blessed $_[0] || $_[0];
Condition0%0/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table0%0/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
86 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
87 return $t->ok(
88 $this->can('MIXIN') &&
89 0 ▶ scalar %{${$this.'::MIXIN'}},
Condition0%0/5
$t->ok($this->can('MIXIN') && scalar %{${$this . '::MIXIN';};}, "'${this}' has MIXINs") || $t->diag(" '${this}' does not have a CLASS constant")
l!l&&r!l&&!r
000
$this->can('MIXIN') && scalar %{${$this . '::MIXIN';};}
!ll
00
MC/DC0%0/2
$t->ok($this->can('MIXIN') && scalar %{${$this . '::MIXIN';};}, "'${this}' has MIXINs") || $t->diag(" '${this}' does not have a CLASS constant")
$t->ok($this->can('MIXIN') && scalar %{${$this . '::MIXIN';};}, "'${this}' has MIXINs") $t->diag(" '${this}' does not have a CLASS constant")
MC/DC0%0/1
$this->can('MIXIN') && scalar %{${$this . '::MIXIN';};}
$this->can('MIXIN')
Truth table0%0/3
A || B
A= $t->ok($this->can('MIXIN') && scalar %{${$this . '::MIXIN';};}, "'${this}' has MIXINs")B= $t->diag(" '${this}' does not have a CLASS constant")
ABresult
1X1
011
000
Truth table0%0/2
A
A= $this->can('MIXIN')
Aresult
00
11
90 "'$this' has MIXINs"
91 )
92 || $t->diag(" '$this' does not have a CLASS constant");
93 }
94  
95 0 ▶sub has_mixins_hash (*) {
Subroutine has_mixins_hash: not called CC=4 SCAR=25.0
Pod documented
96 0 ▶ my $this = blessed $_[0] || $_[0];
Condition0%0/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table0%0/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
97 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
98 return $t->ok(
99 $this->can('MIXIN') &&
100 0 ▶ ref ${$this.'::MIXIN'} eq 'HASH',
Condition0%0/6
$t->ok($this->can('MIXIN') && ref ${$this . '::MIXIN';} eq 'HASH', "'${this}' has MIXIN hash defined") || $t->diag(" '${this}' does not have a MIXIN hash")
l!l&&r!l&&!r
000
$this->can('MIXIN') && ref ${$this . '::MIXIN';} eq 'HASH'
!ll&&!rl&&r
000
MC/DC0%0/2
$t->ok($this->can('MIXIN') && ref ${$this . '::MIXIN';} eq 'HASH', "'${this}' has MIXIN hash defined") || $t->diag(" '${this}' does not have a MIXIN hash")
$t->ok($this->can('MIXIN') && ref ${$this . '::MIXIN';} eq 'HASH', "'${this}' has MIXIN hash defined") $t->diag(" '${this}' does not have a MIXIN hash")
MC/DC0%0/2
$this->can('MIXIN') && ref ${$this . '::MIXIN';} eq 'HASH'
$this->can('MIXIN') ref ${$this . '::MIXIN';} eq 'HASH'
Truth table0%0/3
A || B
A= $t->ok($this->can('MIXIN') && ref ${$this . '::MIXIN';} eq 'HASH', "'${this}' has MIXIN hash defined")B= $t->diag(" '${this}' does not have a MIXIN hash")
ABresult
1X1
011
000
Truth table0%0/3
A && B
A= $this->can('MIXIN')B= ref ${$this . '::MIXIN';} eq 'HASH'
ABresult
0X0
100
111
101 "'$this' has MIXIN hash defined"
102 )
103 || $t->diag(" '$this' does not have a MIXIN hash");
104 }
105  
106 13 ▶sub is_classes (*) {
Subroutine is_classes: called CC=5 SCAR=22.7
Pod documented
107 13 ▶ my $this = blessed $_[0] || $_[0];
Condition33%1/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
0130
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table33%1/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
108 13 ▶ return $t->ok(
Condition33%3/9
$t->ok(&can_new($this) && &has_class_const($this) && &has_decl($this), "'${this}' is a classes class") || $t->diag(" '${this}' does not look like a classes class")
l!l&&r!l&&!r
1300
&can_new($this) && &has_class_const($this) && &has_decl($this)
!ll&&!rl&&r
0013
&can_new($this) and &has_class_const($this)
!ll&&!rl&&r
0013
MC/DC0%0/2
$t->ok(&can_new($this) && &has_class_const($this) && &has_decl($this), "'${this}' is a classes class") || $t->diag(" '${this}' does not look like a classes class")
$t->ok(&can_new($this) && &has_class_const($this) && &has_decl($this), "'${this}' is a classes class") $t->diag(" '${this}' does not look like a classes class")
MC/DC0%0/3
&can_new($this) && &has_class_const($this) && &has_decl($this)
&can_new($this) &has_class_const($this) &has_decl($this)
Truth table33%1/3
A || B
A= $t->ok(&can_new($this) && &has_class_const($this) && &has_decl($this), "'${this}' is a classes class")B= $t->diag(" '${this}' does not look like a classes class")
ABresult
1X1
011
000
Truth table25%1/4
A and B && C
A= &can_new($this)B= &has_class_const($this)C= &has_decl($this)
ABCresult
0XX0
10X0
1100
1111
109 can_new($this) &&
110 has_class_const($this) &&
111 has_decl($this),
112 "'$this' is a classes class"
113 )
114 || $t->diag(" '$this' does not look like a classes class");
115 }
116  
117 4 ▶sub is_throwable (*) {
Subroutine is_throwable: called CC=8 SCAR=31.1
Pod documented
118 4 ▶ my $this = blessed $_[0] || $_[0];
Condition33%1/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
040
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table33%1/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
119 4 ▶ return $t->ok(
Condition33%6/18
$t->ok($this->can('throw') && $this->can('rethrow') && $this->can('send') && $this->can('catch') && $this->can('caught') && $this->can('capture'), "'${this}' fulfills the classes::Throwable interface") || $t->diag(" '${this}' does not fulfill the classes::Throwable interface")
l!l&&r!l&&!r
400
$this->can('throw') && $this->can('rethrow') && $this->can('send') && $this->can('catch') && $this->can('caught') && $this->can('capture')
!ll&&!rl&&r
004
$this->can("throw") and $this->can("rethrow") and $this->can("send") and $this->can("catch") and $this->can("caught")
!ll&&!rl&&r
004
$this->can("throw") and $this->can("rethrow") and $this->can("send") and $this->can("catch")
!ll&&!rl&&r
004
$this->can("throw") and $this->can("rethrow") and $this->can("send")
!ll&&!rl&&r
004
$this->can("throw") and $this->can("rethrow")
!ll&&!rl&&r
004
MC/DC0%0/2
$t->ok($this->can('throw') && $this->can('rethrow') && $this->can('send') && $this->can('catch') && $this->can('caught') && $this->can('capture'), "'${this}' fulfills the classes::Throwable interface") || $t->diag(" '${this}' does not fulfill the classes::Throwable interface")
$t->ok($this->can('throw') && $this->can('rethrow') && $this->can('send') && $this->can('catch') && $this->can('caught') && $this->can('capture'), "'${this}' fulfills the classes::Throwable interface") $t->diag(" '${this}' does not fulfill the classes::Throwable interface")
MC/DC0%0/6
$this->can('throw') && $this->can('rethrow') && $this->can('send') && $this->can('catch') && $this->can('caught') && $this->can('capture')
$this->can("throw") $this->can("rethrow") $this->can("send") $this->can("catch") $this->can("caught") $this->can('capture')
Truth table33%1/3
A || B
A= $t->ok($this->can('throw') && $this->can('rethrow') && $this->can('send') && $this->can('catch') && $this->can('caught') && $this->can('capture'), "'${this}' fulfills the classes::Throwable interface")B= $t->diag(" '${this}' does not fulfill the classes::Throwable interface")
ABresult
1X1
011
000
Truth table14%1/7
A and B and C and D and E && F
A= $this->can("throw")B= $this->can("rethrow")C= $this->can("send")D= $this->can("catch")E= $this->can("caught")F= $this->can('capture')
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
120 $this->can('throw') &&
121 $this->can('rethrow') &&
122 $this->can('send') &&
123 $this->can('catch') &&
124 $this->can('caught') &&
125 $this->can('capture'),
126 "'$this' fulfills the classes::Throwable interface"
127 )
128 || $t->diag(" '$this' does not fulfill the classes::Throwable interface");
129 }
130  
131 3 ▶sub is_classes_exc (*) {
Subroutine is_classes_exc: called CC=6 SCAR=25.9
Pod documented
132 3 ▶ my $this = blessed $_[0] || $_[0];
Condition33%1/3
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
300
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table33%1/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
133 3 ▶ return $t->ok(
Condition33%4/12
$t->ok(&is_classes($this) && $this->can('as_string') && &like(scalar $this->new->as_string, qr/^$this/, 'as_string matches') && &is_throwable($this), "'${this}' is a classes::Exception class") || $t->diag(" '${this}' does not look like a classes::Exception class")
l!l&&r!l&&!r
300
&is_classes($this) && $this->can('as_string') && &like(scalar $this->new->as_string, qr/^$this/, 'as_string matches') && &is_throwable($this)
!ll&&!rl&&r
003
&is_classes($this) and $this->can("as_string") and &like(scalar $this->new->as_string, qr/^$this/, "as_string matches")
!ll&&!rl&&r
003
&is_classes($this) and $this->can("as_string")
!ll&&!rl&&r
003
MC/DC0%0/2
$t->ok(&is_classes($this) && $this->can('as_string') && &like(scalar $this->new->as_string, qr/^$this/, 'as_string matches') && &is_throwable($this), "'${this}' is a classes::Exception class") || $t->diag(" '${this}' does not look like a classes::Exception class")
$t->ok(&is_classes($this) && $this->can('as_string') && &like(scalar $this->new->as_string, qr/^$this/, 'as_string matches') && &is_throwable($this), "'${this}' is a classes::Exception class") $t->diag(" '${this}' does not look like a classes::Exception class")
MC/DC0%0/4
&is_classes($this) && $this->can('as_string') && &like(scalar $this->new->as_string, qr/^$this/, 'as_string matches') && &is_throwable($this)
&is_classes($this) $this->can("as_string") &like(scalar $this->new->as_string, qr/^$this/, "as_string matches") &is_throwable($this)
Truth table33%1/3
A || B
A= $t->ok(&is_classes($this) && $this->can('as_string') && &like(scalar $this->new->as_string, qr/^$this/, 'as_string matches') && &is_throwable($this), "'${this}' is a classes::Exception class")B= $t->diag(" '${this}' does not look like a classes::Exception class")
ABresult
1X1
011
000
Truth table20%1/5
A and B and C && D
A= &is_classes($this)B= $this->can("as_string")C= &like(scalar $this->new->as_string, qr/^$this/, "as_string matches")D= &is_throwable($this)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
134 is_classes($this) &&
135 $this->can('as_string') &&
136 like( $this->new->as_string, qr/^$this/,
137 'as_string matches' ) &&
138 is_throwable($this),
139 "'$this' is a classes::Exception class"
140 )
141 || $t->diag(" '$this' does not look like a classes::Exception class");
142 }
143  
144 5 1;
145  
146 __END__
« classes.pm ↑ Summary