lib/VSGDR/UnitTest/TestSet.pm

filter: Statementstmt 20.5% 33 / 161 Branchbran 0.0% 0 / 72 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 28.1% 9 / 32 Podpod 0.0% 0 / 20 totaltotal 14.2% 42 / 295 SCAR 70.2
CC
41
Cov
14%
actions
72.0
tests
20.0
initializeConditions
20.0
CRAP 1117.4
« lib/VSGDR/UnitTest/TestSet/Representation/NET/CS.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Resx.pm »
1 package VSGDR::UnitTest::TestSet;
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 =head1 NAME
8  
9 VSGDR::UnitTest::TestSet - Sealed class for Microsoft Visual Studio Database Edition UnitTest Utility Suite by Ded MedVed
10  
11 =head1 VERSION
12  
13 Version 1.34
14  
15 =cut
16  
17 1 our $VERSION = '1.34';
18  
19  
20 1 ▶use autodie qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 #TODO 1. Add support for test method attributes eg new vs2010 exceptions ala : -[ExpectedSqlException(MessageNumber = nnnnn, Severity = x, MatchFirstError = false, State = y)]
23  
24 1 ▶use VSGDR::UnitTest::TestSet::Representation ;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶use Clone;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶use base qw(Clone) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 1 our $AUTOLOAD ;
33 1 my %ok_field ;
34 # Authorize four attribute fields
35 {
36 1 for my $attr ( qw(nameSpace className __testCleanupAction __testInitializeAction) ) { $ok_field{$attr}++; }
37 }
38  
39 sub new {
40  
41 0 ▶ local $_ ;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
42  
43 0 my $invocant = shift ;
44 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
45  
46 0 my @elems = @_ ;
47 0 my $self = bless {}, $class ;
48  
49 0 $self->_init(@elems) ;
50 0 return $self ;
51 }
52  
53  
54 sub _init {
55  
56 0 ▶ local $_ ;
Subroutine _init: not called CC=3 SCAR=24.8
57  
58 0 my $self = shift ;
59 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
60 0 ▶ my $ref = shift or croak "no arg";
Branch: 1 branch
BranchTrueFalseTotal
my $ref = shift() or croak("no arg") 0 0 0
61  
62 0 my ${NameSpace} = $$ref{NAMESPACE};
63 0 my ${ClassName} = $$ref{CLASSNAME};
64  
65 0 $self->nameSpace(${NameSpace}) ;
66 0 $self->className(${ClassName}) ;
67 0 $self->initializeConditions([]) ;
68 0 $self->cleanupConditions([]) ;
69 0 return ;
70  
71 }
72  
73 sub tests {
74 0 ▶ local $_ = undef ;
Subroutine tests: not called CC=4 SCAR=30.0
Pod undocumented
75  
76 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
77 0 my $tests ;
78 0 ▶ $tests = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
79 # try to break refees here
80 0 ▶ if ( defined $tests ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tests) 0 0 0
81 0 $self->{TESTS} = $tests ;
82 }
83 0 return $self->{TESTS} ;
84 }
85  
86 sub actions {
87 0 ▶ local $_ = undef ;
Subroutine actions: not called CC=8 SCAR=42.8
Pod undocumented
88  
89 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
90 0 my $actions ;
91 0 ▶ $actions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
92 0 ▶ if ( defined $actions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $actions) 0 0 0
93 0 croak 'obsoleted method';
94 # $self->{ACTIONS} = $actions ;
95 }
96 0 my %actions = () ;
97 0 my $ra_tests = $self->tests() ;
98 0 foreach my $test ( @$ra_tests ) {
99 #warn Dumper $test ;
100 0 my $rh_= $test->actions() ;
101 0 foreach my $action ( keys %$rh_ ) {
102 #warn Dumper $action ;
103 0 $actions{$action} = 1 ;
104 }
105 }
106 #warn Dumper %actions ;
107 0 ▶ $actions{$self->initializeAction()} = 1 if defined $self->initializeAction() ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->initializeAction 0 0 0
108 0 ▶ $actions{$self->cleanupAction()} = 1 if defined $self->cleanupAction() ;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->cleanupAction 0 0 0
109 0 return \%actions ;
110 }
111  
112  
113 sub initializeConditions {
114 0 ▶ local $_ = undef ;
Subroutine initializeConditions: not called CC=4 SCAR=30.0
Pod undocumented
115  
116 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
117 0 my $conditions ;
118 0 ▶ $conditions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
119 0 ▶ if ( defined $conditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conditions) 0 0 0
120 0 $self->{INITIALIZECONDITIONS} = $conditions ;
121 }
122 0 return $self->{INITIALIZECONDITIONS} ;
123 }
124  
125 sub cleanupConditions {
126 0 ▶ local $_ = undef ;
Subroutine cleanupConditions: not called CC=4 SCAR=30.0
Pod undocumented
127  
128 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
129 0 my $conditions ;
130 0 ▶ $conditions = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
131 0 ▶ if ( defined $conditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conditions) 0 0 0
132 0 $self->{CLEANUPCONDITIONS} = $conditions ;
133 }
134 0 return $self->{CLEANUPCONDITIONS} ;
135 }
136  
137 sub commentifyAny {
138 0 ▶ local $_ = undef ;
Subroutine commentifyAny: not called CC=3 SCAR=24.8
Pod undocumented
139  
140 0 my $self = shift;
141 0 ▶ my $commentChars = shift or die 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or die "No Chars" 0 0 0
142 0 ▶ my $thing = shift or die 'No thing' ;
Branch: 1 branch
BranchTrueFalseTotal
my $thing = shift() or die "No thing" 0 0 0
143 0 return <<"EOF";
144 ${commentChars}
145 ${commentChars}${thing}
146 ${commentChars}
147 EOF
148 }
149  
150 sub commentifyInitializeAction {
151 0 ▶ local $_ = undef ;
Subroutine commentifyInitializeAction: not called CC=2 SCAR=17.9
Pod undocumented
152  
153 0 my $self = shift;
154 0 ▶ my $commentChars = shift or die 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or die "No Chars" 0 0 0
155 0 return <<"EOF";
156 ${commentChars}
157 0 ${commentChars}@{[$self->initializeAction()]}
158 ${commentChars}
159 EOF
160 }
161  
162 sub commentifyCleanupAction {
163 0 ▶ local $_ = undef ;
Subroutine commentifyCleanupAction: not called CC=2 SCAR=17.9
Pod undocumented
164  
165 0 my $self = shift;
166 0 ▶ my $commentChars = shift or die 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or die "No Chars" 0 0 0
167 0 return <<"EOF";
168 ${commentChars}
169 0 ${commentChars}@{[$self->cleanupAction()]}
170 ${commentChars}
171 EOF
172 }
173  
174 sub commentifyClassName {
175 0 ▶ local $_ = undef ;
Subroutine commentifyClassName: not called CC=2 SCAR=17.9
Pod undocumented
176  
177 0 my $self = shift;
178 0 ▶ my $commentChars = shift or die 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or die "No Chars" 0 0 0
179 0 return <<"EOF";
180 ${commentChars}
181 0 ${commentChars}@{[$self->className()]}
182 ${commentChars}
183 EOF
184 }
185 sub initializeAction {
186 0 ▶ local $_ = undef ;
Subroutine initializeAction: not called CC=4 SCAR=30.0
Pod undocumented
187  
188 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
189 0 my $action ;
190 0 ▶ $action = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
191 0 ▶ if ( defined $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action) 0 0 0
192 0 $self->__testInitializeAction($action) ;
193 }
194 0 return $self->__testInitializeAction() ;
195 }
196  
197 sub cleanupAction {
198 0 ▶ local $_ = undef ;
Subroutine cleanupAction: not called CC=4 SCAR=30.0
Pod undocumented
199  
200 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
201 0 my $action ;
202 0 ▶ $action = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
203 0 ▶ if ( defined $action ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $action) 0 0 0
204 0 $self->__testCleanupAction($action) ;
205 }
206 0 return $self->__testCleanupAction() ;
207  
208 }
209  
210 sub initializeActionLiteral {
211 0 ▶ local $_ = undef ;
Subroutine initializeActionLiteral: not called CC=2 SCAR=17.9
Pod undocumented
212  
213 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
214 0 return 'testInitializeAction' ;
215 }
216  
217 sub cleanupActionLiteral {
218 0 ▶ local $_ = undef ;
Subroutine cleanupActionLiteral: not called CC=2 SCAR=17.9
Pod undocumented
219  
220 0 ▶ my $self = shift or croak 'no self';
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
221 0 return 'testCleanupAction' ;
222  
223 }
224  
225 sub allConditionAttributeNames {
226 0 ▶ local $_ = undef ;
Subroutine allConditionAttributeNames: not called CC=1 SCAR=6.9
Pod undocumented
227  
228 0 my $self = shift;
229 0 return ('Type','Name','ResultSet','RowNumber','ColumnNumber','ExpectedValue','RowCount','NullExpected','ExecutionTime','Enabled') ;
230 }
231  
232 sub generate {
233 0 ▶ local $_ = undef ;
Subroutine generate: not called CC=2 SCAR=17.9
Pod undocumented
234  
235 0 my $self = shift;
236 0 ▶ my $generator_type = shift or croak "No generator supplied" ;
Branch: 1 branch
BranchTrueFalseTotal
my $generator_type = shift() or croak("No generator supplied") 0 0 0
237 0 my $generator = VSGDR::UnitTest::TestSet::Representation->make( { TYPE => $generator_type } ) ;
238 0 return $generator->deparse($self);
239 }
240  
241 sub AST {
242 0 ▶ local $_ = undef ;
Subroutine AST: not called CC=2 SCAR=17.9
Pod undocumented
243  
244 0 ▶ my $self = shift or croak "No self" ;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("No self") 0 0 0
245 0 return { HEAD => { NAMESPACE => $self->nameSpace()
246 , CLASSNAME => $self->className()
247 , INITIALIZEACTION => $self->__testInitializeAction()
248 , CLEANUPACTION => $self->__testCleanupAction()
249 }
250 , INITIALIZECONDITIONS => $self->initializeConditions()
251 , CLEANUPCONDITIONS => $self->cleanupConditions()
252 , BODY => $self->tests()
253 , ACTIONS => $self->actions()
254 }
255 }
256  
257 sub renameTest {
258 0 ▶ local $_ = undef ;
Subroutine renameTest: not called CC=3 SCAR=24.8
Pod undocumented
259  
260 0 my $self = shift;
261 0 ▶ my $oldTestName = shift or croak "No old Test Name supplied" ;
Branch: 1 branch
BranchTrueFalseTotal
my $oldTestName = shift() or croak("No old Test Name supplied") 0 0 0
262 0 ▶ my $newTestName = shift or croak "No new Test Name supplied" ;
Branch: 1 branch
BranchTrueFalseTotal
my $newTestName = shift() or croak("No new Test Name supplied") 0 0 0
263  
264 0 return ;
265 }
266  
267 sub deleteTest {
268 0 ▶ local $_ = undef ;
Subroutine deleteTest: not called CC=2 SCAR=17.9
Pod undocumented
269  
270 0 my $self = shift;
271 0 ▶ my $testName = shift or croak "No Test Name supplied" ;
Branch: 1 branch
BranchTrueFalseTotal
my $testName = shift() or croak("No Test Name supplied") 0 0 0
272  
273 0 return ;
274  
275 }
276  
277 sub Dump {
278 0 ▶ local $_ = undef ;
Subroutine Dump: not called CC=1 SCAR=6.9
Pod undocumented
279  
280 0 warn "!\n";
281 0 warn Dumper @_ ;
282 0 warn "!\n";
283 0 return ;
284 }
285  
286 0 ▶sub flatten { return map { @$_} @_ } ;
Subroutine flatten: not called CC=1 SCAR=6.9
Pod undocumented
287  
288 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
289  
290 sub AUTOLOAD {
291 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=4 SCAR=30.0
292 0 my $attr = $AUTOLOAD;
293 0 $attr =~ s{.*::}{}x;
294 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
295 0 ▶ croak "invalid attribute method: ->$attr()" unless $ok_field{$attr};
Branch: 1 branch
BranchTrueFalseTotal
unless $ok_field{$attr} 0 0 0
296 0 ▶ $self->{uc $attr} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
297 0 return $self->{uc $attr};
298 }
299  
300 1 1 ;
301  
302 __DATA__
« lib/VSGDR/UnitTest/TestSet/Representation/NET/CS.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Resx.pm »