lib/VSGDR/UnitTest/TestSet/Test/TestCondition.pm

filter: Statementstmt 27.9% 19 / 68 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 35.2% 6 / 17 Podpod 0.0% 0 / 9 totaltotal 20.3% 25 / 123 SCAR 47.4
CC
14
Cov
20%
AUTOLOAD
20.0
make
12.0
testConditionAttributeType
12.0
CRAP 114.4
« lib/VSGDR/UnitTest/TestSet/Test/TestCondition/ScalarValue.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Representation.pm »
1 package VSGDR::UnitTest::TestSet::Test::TestCondition;
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 #TODO 1. Add support for test method attributes eg new vs2010 exceptions ala : -[ExpectedSqlException(MessageNumber = nnnnn, Severity = x, MatchFirstError = false, State = y)]
12  
13  
14 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17  
18 1 ▶use vars qw($AUTOLOAD );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 my %Types = (ScalarValue=> 1
21 ,EmptyResultSet=> 1
22 ,ExecutionTime=> 1
23 ,Inconclusive=> 1
24 ,NotEmptyResultSet=> 1
25 ,RowCount=> 1
26 ,Checksum=>1
27 ,ExpectedSchema=>1
28 );
29  
30 sub make {
31  
32 0 ▶ local $_ = undef ;
Subroutine make: not called CC=3 SCAR=24.8
Pod undocumented
33 0 my $self = shift ;
34 0 ▶ my $objectType = $_[0]->{TESTCONDITIONTYPE} or croak 'No object type' ;
Branch: 1 branch
BranchTrueFalseTotal
my $objectType = $_[0]{"TESTCONDITIONTYPE"} or croak("No object type") 0 0 0
35 0 ▶ croak "Invalid Test Condition Type" unless exists $Types{$objectType };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Types{$objectType} 0 0 0
36
37 0 require "VSGDR/UnitTest/TestSet/Test/TestCondition/${objectType}.pm";
38 0 return "VSGDR::UnitTest::TestSet::Test::TestCondition::${objectType}"->new(@_) ;
39  
40 }
41  
42 sub new {
43  
44 0 ▶ local $_ = undef ;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
45  
46 0 my $invocant = shift ;
47 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
48  
49 0 my @elems = @_ ;
50 0 my $self = bless {}, $class ;
51
52 0 $self->_init(@elems) ;
53 0 return $self ;
54 }
55  
56  
57 sub ok_field {
58 0 ▶ my $self = shift;
Subroutine ok_field: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my $attr = shift;
60 0 return $self->{OK_FIELDS}->{$attr} ;
61 }
62  
63 sub commentifyName {
64 0 ▶ my $self = shift;
Subroutine commentifyName: not called CC=2 SCAR=17.9
Pod undocumented
65 0 ▶ my $commentChars = shift or croak 'No Chars' ;
Branch: 1 branch
BranchTrueFalseTotal
my $commentChars = shift() or croak("No Chars") 0 0 0
66 0 return <<"EOF";
67 ${commentChars}
68 0 ${commentChars}@{[$self->conditionName()]}
69 ${commentChars}
70 EOF
71 }
72  
73 sub testAction {
74 0 ▶ my $self = shift;
Subroutine testAction: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my $ta = $self->{CONDITIONTESTACTIONNAME} ;
76 0 return $ta;
77 }
78  
79 sub testConditionAttributes {
80 0 ▶ my $self = shift;
Subroutine testConditionAttributes: not called CC=1 SCAR=6.9
Pod undocumented
81 0 return keys %{$self->{OK_FIELDS}} ;
82 }
83 sub testConditionAttributeType {
84 0 ▶ my $self = shift;
Subroutine testConditionAttributeType: not called CC=3 SCAR=24.8
Pod undocumented
85 0 ▶ my $attr = shift or croak 'no attribute' ;
Branch: 1 branch
BranchTrueFalseTotal
my $attr = shift() or croak("no attribute") 0 0 0
86 0 ▶ croak 'bad attribute'unless $self->ok_field($attr) ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ok_field($attr) 0 0 0
87 #warn Dumper $self->{OK_FIELDS_TYPE} ;
88 0 return $self->{OK_FIELDS_TYPE}->{$attr} ;
89 }
90  
91 sub testConditionAttributeName {
92 0 ▶ my $self = shift;
Subroutine testConditionAttributeName: not called CC=3 SCAR=24.8
Pod undocumented
93 0 ▶ my $attr = shift or croak 'no attribute' ;
Branch: 1 branch
BranchTrueFalseTotal
my $attr = shift() or croak("no attribute") 0 0 0
94 0 ▶ croak 'bad attribute'unless $self->ok_field($attr) ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ok_field($attr) 0 0 0
95 0 ( my $n = $attr ) =~ s{^condition}{}x;
96 0 return $n ;
97 }
98  
99 sub conditionISEnabled {
100 0 ▶ local $_ = undef ;
Subroutine conditionISEnabled: not called CC=3 SCAR=24.8
Pod undocumented
101 0 my $self = shift ;
102 0 ▶ if ( $self->conditionEnabled() =~ m{\A 1 \z}ix ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->conditionEnabled =~ /\A 1 \z/xi) { } 0 0 0
elsif ($self->conditionEnabled =~ /\A True \z/xi) { } 0 0 0
103 0 return scalar 1 ;
104 }
105 elsif ( $self->conditionEnabled() =~ m{\A True \z}ix ) {
106 0 return scalar 1 ;
107 }
108 else {
109 0 return scalar 0 ;
110 }
111 }
112  
113  
114  
115  
116 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
117  
118 sub AUTOLOAD {
119 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=4 SCAR=30.0
120 0 my $attr = $AUTOLOAD;
121 #warn Dumper $attr ;
122 0 $attr =~ s{.*::}{}x;
123 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
124 #warn Dumper $attr ;
125 #warn Dumper $ok_field{$attr} ;
126 #warn Dumper %ok_field;
127 0 ▶ croak "invalid attribute method: ->$attr()" unless $self->ok_field($attr);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ok_field($attr) 0 0 0
128
129 0 my $UC_ATTR = uc $attr ;
130
131 0 ▶ $self->{$UC_ATTR} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
132 0 return $self->{$UC_ATTR};
133 }
134  
135  
136 1 1 ;
137  
138 __DATA__
« lib/VSGDR/UnitTest/TestSet/Test/TestCondition/ScalarValue.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Representation.pm »