lib/VSGDR/UnitTest/TestSet/Test.pm

filter: Statementstmt 14.1% 22 / 156 Branchbran 0.0% 0 / 76 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 20.0% 6 / 30 Podpod 0.0% 0 / 21 totaltotal 9.5% 28 / 293 SCAR 72.2
CC
42
Cov
9%
_init
30.0
actions
30.0
preTestAction
30.0
CRAP 1360.6
« lib/VSGDR/UnitTest/TestSet/Representation/NET/VB.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Representation/NET2.pm »
1 package VSGDR::UnitTest::TestSet::Test;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 #our \$VERSION = '1.01';
9  
10  
11 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 1 ▶use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 my %ok_field;
17  
18 # Authorize four attribute fields
19 {
20 #for my $attr ( qw(nameSpace className testName testDataName ) ) { $ok_field{$attr}++; }
21 #for my $attr ( qw(testName testActionDataName postTestAction testAction preTestAction) ) { $ok_field{$attr}++; }
22 1 for my $attr ( qw(testName testActionDataName ) ) { $ok_field{$attr}++; }
23 }
24 sub new {
25  
26 0 ▶ local $_ = undef ;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
27  
28 #warn Dumper @_;
29  
30 0 my $invocant = shift ;
31 0 ▶ my $class = ref($invocant) || $invocant ;
Condition0%0/3
ref $invocant || $invocant
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant $invocant
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
ABresult
1X1
011
000
32  
33 0 my @elems = @_ ;
34 0 my $self = bless {}, $class ;
35
36 0 $self->_init(@elems) ;
37 0 return $self ;
38 }
39  
40  
41 sub _init {
42  
43 0 ▶ local $_ = undef ;
Subroutine _init: not called CC=5 SCAR=34.0
44  
45 #warn Dumper @_;
46  
47 0 my $self = shift ;
48 0 ▶ my $class = ref($self) || $self ;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
49 0 ▶ my $ref = shift or croak "no arg";
Branch: 1 branch
BranchTrueFalseTotal
my $ref = shift() or croak("no arg") 0 0 0
50  
51 #print Dumper $ref ;
52  
53 0 for my $attr ( qw(TESTNAME TESTACTIONDATANAME PRETESTACTION TESTACTION POSTTESTACTION ) ) { $self->{OK_PARAMS}{$attr}++; }
54 0 my @validargs = grep { $$ref{$_} } keys %{$self->{OK_PARAMS}} ;
55 #warn Dumper @validargs ;
56 0 ▶ croak "bad args"
Branch: 1 branch
BranchTrueFalseTotal
if scalar @validargs != 5 0 0 0
57 if scalar(@validargs) != 5 ;
58  
59  
60 0 my ${TestName} = $$ref{TESTNAME};
61 0 my ${TestActionDataName} = $$ref{TESTACTIONDATANAME};
62 0 my ${PreTestAction} = $$ref{PRETESTACTION};
63 0 my ${TestAction} = $$ref{TESTACTION};
64 0 my ${PostTestAction} = $$ref{POSTTESTACTION};
65  
66 0 $self->testName(${TestName}) ;
67 0 $self->testActionDataName(${TestActionDataName}) ;
68 0 $self->preTestAction(${PreTestAction}) ;
69 0 $self->testAction(${TestAction}) ;
70 0 $self->postTestAction(${PostTestAction}) ;
71
72 0 $self->{TESTCONDITIONS} = [] ;
73
74 0 $self->{PRETEST_TESTCONDITIONS} = [] ;
75 0 $self->{TEST_TESTCONDITIONS} = [] ;
76 0 $self->{POSTTEST_TESTCONDITIONS} = [] ;
77
78 #multiple tests
79 #each with multiple actions
80 #each with multiple conditions
81  
82 # $self->testName(${TestName}) ;
83 # $self->testDataName(${TestDataName}) ;
84
85 0 return ;
86
87 }
88  
89 #-- TODO --->
90 sub actions {
91 0 ▶ my $self = shift or croak 'no self';
Subroutine actions: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
92 0 my %actions ;
93  
94 0 ▶ if ( $self->preTestAction() !~ m/^(?:null|nothing)$/ix ) { $actions{$self->testName()."_".$self->preTestAction()} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->preTestAction =~ /^(?:null|nothing)$/xi) 0 0 0
95 0 ▶ if ( $self->testAction() !~ m/^(?:null|nothing)$/ix ) { $actions{$self->testName()."_".$self->testAction()} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->testAction =~ /^(?:null|nothing)$/xi) 0 0 0
96 0 ▶ if ( $self->postTestAction() !~ m/^(?:null|nothing)$/ix ) { $actions{$self->testName()."_".$self->postTestAction()} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->postTestAction =~ /^(?:null|nothing)$/xi) 0 0 0
97
98 0 return \%actions ;
99 }
100  
101 #sub hasAction {
102 # my $self = shift or croak 'no self';
103 # my $action = shift ;
104 # croak 'No action requested' if not defined $action;
105 # return exists($self->{ACTIONS}{$action}) ;
106 #}
107  
108  
109  
110 sub preTestActionLiteral {
111 0 ▶ my $self = shift;
Subroutine preTestActionLiteral: not called CC=1 SCAR=6.9
Pod undocumented
112 0 return "PretestAction";
113 }
114 sub testActionLiteral {
115 0 ▶ my $self = shift;
Subroutine testActionLiteral: not called CC=1 SCAR=6.9
Pod undocumented
116 0 return "TestAction";
117 }
118 sub postTestActionLiteral {
119 0 ▶ my $self = shift;
Subroutine postTestActionLiteral: not called CC=1 SCAR=6.9
Pod undocumented
120 0 return "PosttestAction";
121 }
122  
123 sub preTestActionLiteralName {
124 0 ▶ my $self = shift;
Subroutine preTestActionLiteralName: not called CC=1 SCAR=6.9
Pod undocumented
125 0 return $self->testName . '_' . $self->preTestActionLiteral() ;
126 }
127 sub testActionLiteralName {
128 0 ▶ my $self = shift;
Subroutine testActionLiteralName: not called CC=1 SCAR=6.9
Pod undocumented
129 0 return $self->testName . '_' . $self->testActionLiteral() ;
130 }
131 sub postTestActionLiteralName {
132 0 ▶ my $self = shift;
Subroutine postTestActionLiteralName: not called CC=1 SCAR=6.9
Pod undocumented
133 0 return $self->testName . '_' . $self->postTestActionLiteral() ;
134 }
135  
136 sub commentifyTestName {
137 0 ▶ my $self = shift;
Subroutine commentifyTestName: not called CC=2 SCAR=17.9
Pod undocumented
138 0 ▶ my $commentChars = shift or croak 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or croak("No Chars") 0 0 0
139 0 return <<"EOF";
140 ${commentChars}
141 0 ${commentChars}@{[$self->testName()]}
142 ${commentChars}
143 EOF
144 }
145  
146  
147 sub commentifyPreTestAction {
148 0 ▶ my $self = shift;
Subroutine commentifyPreTestAction: not called CC=2 SCAR=17.9
Pod undocumented
149 0 ▶ my $commentChars = shift or croak 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or croak("No Chars") 0 0 0
150 0 return <<"EOF";
151 ${commentChars}
152 0 ${commentChars}@{[$self->preTestAction()]}
153 ${commentChars}
154 EOF
155 }
156  
157 sub commentifyTestAction {
158 0 ▶ my $self = shift;
Subroutine commentifyTestAction: not called CC=2 SCAR=17.9
Pod undocumented
159 0 ▶ my $commentChars = shift or croak 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or croak("No Chars") 0 0 0
160 0 return <<"EOF";
161 ${commentChars}
162 0 ${commentChars}@{[$self->testAction()]}
163 ${commentChars}
164 EOF
165 }
166  
167 sub commentifyPostTestAction {
168 0 ▶ my $self = shift;
Subroutine commentifyPostTestAction: not called CC=2 SCAR=17.9
Pod undocumented
169 0 ▶ my $commentChars = shift or croak 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or croak("No Chars") 0 0 0
170 0 return <<"EOF";
171 ${commentChars}
172 0 ${commentChars}@{[$self->postTestAction()]}
173 ${commentChars}
174 EOF
175 }
176  
177 sub commentifyActionDataName {
178 0 ▶ my $self = shift;
Subroutine commentifyActionDataName: not called CC=2 SCAR=17.9
Pod undocumented
179 0 ▶ my $commentChars = shift or croak 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or croak("No Chars") 0 0 0
180 0 return <<"EOF";
181 ${commentChars}
182 0 ${commentChars}@{[$self->testActionDataName()]}
183 ${commentChars}
184 EOF
185 }
186  
187 sub preTest_conditions {
188 0 ▶ my $self = shift or croak 'no self';
Subroutine preTest_conditions: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
189 0 my $conditions ;
190 0 ▶ $conditions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
191 0 ▶ if ( defined $conditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conditions) 0 0 0
192 0 my @conditions = @$conditions ;
193 0 $self->{PRETEST_TESTCONDITIONS} = \@conditions ;
194 }
195 0 return $self->{PRETEST_TESTCONDITIONS} ;
196 }
197  
198 sub test_conditions {
199 0 ▶ my $self = shift or croak 'no self';
Subroutine test_conditions: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
200 0 my $conditions ;
201 0 ▶ $conditions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
202 0 ▶ if ( defined $conditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conditions) 0 0 0
203 0 my @conditions = @$conditions ;
204 0 $self->{TEST_TESTCONDITIONS} = \@conditions ;
205 }
206 0 return $self->{TEST_TESTCONDITIONS} ;
207 }
208  
209 sub postTest_conditions {
210 0 ▶ my $self = shift or croak 'no self';
Subroutine postTest_conditions: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
211 0 my $conditions ;
212 0 ▶ $conditions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
213 0 ▶ if ( defined $conditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conditions) 0 0 0
214 0 my @conditions = @$conditions ;
215 0 $self->{POSTTEST_TESTCONDITIONS} = \@conditions ;
216 }
217 0 return $self->{POSTTEST_TESTCONDITIONS} ;
218 }
219  
220 sub conditions {
221 0 ▶ my $self = shift or croak 'no self';
Subroutine conditions: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
222 0 my $conditions ;
223 0 ▶ $conditions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
224 0 ▶ if ( defined $conditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conditions) 0 0 0
225 0 croak 'obsoleted method' ;
226 }
227 0 my $preTestConditions = $self->preTest_conditions() ;
228 0 my $testConditions = $self->test_conditions() ;
229 0 my $postTestConditions = $self->postTest_conditions() ;
230 0 my @Conditions = flatten ([@$preTestConditions,@$testConditions,@$postTestConditions]);
231
232 0 return \@Conditions ;
233 }
234  
235 sub preTestAction {
236 0 ▶ my $self = shift or croak 'no self';
Subroutine preTestAction: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
237 0 my $action ;
238 0 ▶ $action = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
239 # normalise
240 0 ▶ if ( defined $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action) 0 0 0
241 0 ▶ $action = 'null' if $action =~ m{^null|nothing$}ix ;
Branch: 1 branch
BranchTrueFalseTotal
if $action =~ /^null|nothing$/xi 0 0 0
242 0 $self->{PRETESTACTION} = $action ;
243 }
244 0 return $self->{PRETESTACTION} ;
245  
246 }
247 sub testAction {
248 0 ▶ my $self = shift or croak 'no self';
Subroutine testAction: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
249 0 my $action ;
250 0 ▶ $action = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
251 # normalise
252 0 ▶ if ( defined $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action) 0 0 0
253 0 ▶ $action = 'null' if $action =~ m{^null|nothing$}ix ;
Branch: 1 branch
BranchTrueFalseTotal
if $action =~ /^null|nothing$/xi 0 0 0
254 0 $self->{TESTACTION} = $action ;
255 }
256 0 return $self->{TESTACTION} ;
257  
258 }
259 sub postTestAction {
260 0 ▶ my $self = shift or croak 'no self';
Subroutine postTestAction: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
261 0 my $action ;
262 0 ▶ $action = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
263 # normalise
264 0 ▶ if ( defined $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action) 0 0 0
265 0 ▶ $action = 'null' if $action =~ m{^null|nothing$}ix ;
Branch: 1 branch
BranchTrueFalseTotal
if $action =~ /^null|nothing$/xi 0 0 0
266 0 $self->{POSTTESTACTION} = $action ;
267 }
268 0 return $self->{POSTTESTACTION} ;
269  
270 }
271  
272  
273 0 ▶sub flatten { return map { @$_} @_ } ;
Subroutine flatten: not called CC=1 SCAR=6.9
Pod undocumented
274  
275 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
276  
277 sub AUTOLOAD {
278 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=4 SCAR=30.0
279 0 my $attr = $AUTOLOAD;
280 0 $attr =~ s{.*::}{}x;
281 0 ▶ return unless $attr =~ m{[^A-Z]}x; # skip DESTROY and all-cap methods
Branch: 1 branch
BranchTrueFalseTotal
unless $attr =~ /[^A-Z]/x 0 0 0
282 0 ▶ croak "invalid attribute method: ->$attr()" unless $ok_field{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $ok_field{$attr} 0 0 0
283 0 ▶ $self->{uc $attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
284 0 return $self->{uc $attr};
285 }
286  
287 1 1 ;
288  
289 __DATA__
« lib/VSGDR/UnitTest/TestSet/Representation/NET/VB.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Representation/NET2.pm »