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

filter: Statementstmt 35.1% 32 / 91 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 4 totaltotal 23.8% 40 / 168 SCAR 52.0
CC
19
Cov
23%
check
210.0
_init
20.0
conditionNullISExpected
12.0
CRAP 181.5
« lib/VSGDR/UnitTest/TestSet/Representation/NET2/VB.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Test/TestCondition.pm »
1 package VSGDR::UnitTest::TestSet::Test::TestCondition::ScalarValue;
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 #our \$VERSION = '1.01';
8  
9  
10 1 ▶use parent qw(VSGDR::UnitTest::TestSet::Test::TestCondition) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 BEGIN {
12 1 ▶*AUTOLOAD = \&VSGDR::UnitTest::TestSet::Test::TestCondition::AUTOLOAD ;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 }
14  
15 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 1 ▶use vars qw($AUTOLOAD %ok_field);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 #TODO 1: Sort out value testing you damn fool.
22  
23 # Authorize constructor hash fields
24 1 my %ok_params = () ;
25 1 for my $attr ( qw(CONDITIONTESTACTIONNAME CONDITIONNAME CONDITIONENABLED CONDITIONEXPECTEDVALUE CONDITIONNULLEXPECTED CONDITIONRESULTSET CONDITIONROWNUMBER CONDITIONCOLUMNNUMBER) ) { $ok_params{$attr}++; }
26 1 my %ok_fields = () ;
27 1 my %ok_fields_type = () ;
28 # Authorize attribute fields
29 1 for my $attr ( qw(conditionTestActionName conditionName conditionEnabled conditionExpectedValue conditionResultSet conditionNullExpected conditionRowNumber conditionColumnNumber) ) { $ok_fields{$attr}++; $ok_fields_type{$attr} = 'plain'; }
30 1 $ok_fields_type{conditionName} = 'quoted';
31 1 $ok_fields_type{conditionEnabled} = 'bool';
32  
33 sub _init {
34  
35 0 ▶ local $_ = undef ;
Subroutine _init: not called CC=4 SCAR=30.0
36  
37 0 my $self = shift ;
38 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
39 0 ▶ my $ref = shift or croak "no arg";
Branch: 1 branch
BranchTrueFalseTotal
my $ref = shift() or croak("no arg") 0 0 0
40  
41 0 $self->{OK_PARAMS} = \%ok_params ;
42 0 $self->{OK_FIELDS} = \%ok_fields ;
43 0 $self->{OK_FIELDS_TYPE} = \%ok_fields_type ;
44 0 my @validargs = grep { exists($$ref{$_}) } keys %{$self->{OK_PARAMS}} ;
45 0 ▶ croak "bad args"
Branch: 1 branch
BranchTrueFalseTotal
if scalar @validargs != 8 0 0 0
46 if scalar(@validargs) != 8 ;
47  
48 0 my ${Name} = $$ref{CONDITIONNAME};
49 0 my ${TestActionName} = $$ref{CONDITIONTESTACTIONNAME};
50 0 my ${Enabled} = $$ref{CONDITIONENABLED};
51 0 my ${ExpectedValue} = $$ref{CONDITIONEXPECTEDVALUE};
52 0 my ${NullExpected} = $$ref{CONDITIONNULLEXPECTED};
53 0 my ${ResultSet} = $$ref{CONDITIONRESULTSET};
54 0 my ${RowNumber} = $$ref{CONDITIONROWNUMBER};
55 0 my ${ColumnNumber} = $$ref{CONDITIONCOLUMNNUMBER};
56  
57 0 $self->conditionName(${Name}) ;
58 0 $self->conditionTestActionName(${TestActionName}) ;
59 0 $self->conditionEnabled(${Enabled}) ;
60 0 $self->conditionExpectedValue(${ExpectedValue}) ;
61 0 $self->conditionNullExpected(${NullExpected}) ;
62 0 $self->conditionResultSet(${ResultSet}) ;
63 0 $self->conditionRowNumber(${RowNumber}) ;
64 0 $self->conditionColumnNumber(${ColumnNumber}) ;
65  
66
67 0 return ;
68
69 }
70  
71 sub testConditionType {
72 0 ▶ my $self = shift;
Subroutine testConditionType: not called CC=1 SCAR=6.9
Pod undocumented
73 0 return 'ScalarValue' ;
74 }
75  
76 sub testConditionMSType {
77 0 ▶ return 'ScalarValueCondition' ;
Subroutine testConditionMSType: not called CC=1 SCAR=6.9
Pod undocumented
78 }
79  
80 sub check {
81 0 ▶ local $_ = undef ;
Subroutine check: not called CC=14 SCAR=53.5
Pod undocumented
82 0 my $self = shift ;
83 0 my $ra_res = shift ;
84  
85 #warn Dumper $ra_res ;
86 #warn $self->conditionEnabled() ;
87  
88 # unquote scalar string values
89 # should use Data method but that's in entirely the wrong class
90 0 my $unQuotedValue = $self->conditionExpectedValue() ;
91 0 $unQuotedValue =~ s{\\"}{"}gms; #" kill TextPad syntax highlighting
92
93 0 ▶ if ( $self->conditionISEnabled() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->conditionISEnabled) { } 0 0 0
94 0 ▶ if ( not $self->conditionNullISExpected() and not defined( $ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1]) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->conditionNullISExpected || defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]) { } 0 0 0
elsif ($self->conditionNullISExpected and not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] or '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValue or $unQuotedValue =~ /^"true"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq '1' or $unQuotedValue =~ /^"false"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq '0') { } 0 0 0
Condition0%0/3
$self->conditionNullISExpected || defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->conditionNullISExpected || defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]
$self->conditionNullISExpected defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]
Truth table0%0/3
A || B
A= $self->conditionNullISExpectedB= defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]
ABresult
1X1
011
000
95 0 say 'Condition is ', $self->conditionName() ;
96 0 say 'value is ', 'undef' ;
97 0 say 'expected was ', $unQuotedValue ;
98 0 return scalar 0 ;
99 }
100 ▶ elsif ( ( $self->conditionNullISExpected() and not defined( $ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1]) ) or
Condition0%0/18
$self->conditionNullISExpected and not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] or '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValue or $unQuotedValue =~ /^"true"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 1 or $unQuotedValue =~ /^"false"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 0
l!l&&r!l&&!r
000
$self->conditionNullISExpected and not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] or '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValue or $unQuotedValue =~ /^"true"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 1
l!l&&r!l&&!r
000
$self->conditionNullISExpected and not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] or '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValue
l!l&&r!l&&!r
000
$self->conditionNullISExpected and not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]
!ll&&!rl&&r
000
$unQuotedValue =~ /^"true"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 1
!ll&&!rl&&r
000
$unQuotedValue =~ /^"false"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 0
!ll&&!rl&&r
000
MC/DC0%0/7
$self->conditionNullISExpected and not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] or '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValue or $unQuotedValue =~ /^"true"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 1 or $unQuotedValue =~ /^"false"$/i and $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 0
$self->conditionNullISExpected not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValue $unQuotedValue =~ /^"true"$/i $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 1 $unQuotedValue =~ /^"false"$/i $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 0
Truth table0%0/17
A and not(B) or C or D and E or F and G
A= $self->conditionNullISExpectedB= not defined $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1]C= '"' . $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] . '"' eq $unQuotedValueD= $unQuotedValue =~ /^"true"$/iE= $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 1F= $unQuotedValue =~ /^"false"$/iG= $$ra_res[$self->conditionResultSet - 1][$self->conditionRowNumber - 1][$self->conditionColumnNumber - 1] eq 0
ABCDEFGresult
11XXXXX1
0X1XXXX1
101XXXX1
0X011XX1
10011XX1
0X00X111
0X010111
1000X111
10010111
0X00X0X0
0X00X100
0X0100X0
0X010100
1000X0X0
1000X100
100100X0
10010100
101
102 ( '"'.$ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1].'"' eq $unQuotedValue )
103 # horrible hack around for now ........... where was my nice clean fix.
104 or ( ( $unQuotedValue =~ m{^"true"$}i ) and ( $ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1] eq "1" ) )
105 or ( ( $unQuotedValue =~ m{^"false"$}i ) and ( $ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1] eq "0" ) )
106 ) {
107 0 return scalar 1 ;
108 }
109 else {
110 # another hackaround for date values
111 0 my $v = $ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1] ;
112 0 my $v2 = $unQuotedValue ;
113 0 ( my $v3 = $v2 ) =~ s{/}{-}g;
114  
115 #warn $v;
116 #warn $v2;
117 #warn $v3;
118 #warn substr $v3, 1 , 10 ;
119 #warn substr $v, 0, 10;
120  
121 0 ▶ if ( ( $v =~ m{^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $}x )
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $/x and $v2 =~ m[^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $]x and substr($v3, 1, 10) eq substr($v, 0, 10)) { } 0 0 0
Condition0%0/6
$v =~ /^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $/x and $v2 =~ m[^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $]x and substr($v3, 1, 10) eq substr($v, 0, 10)
!ll&&!rl&&r
000
$v =~ /^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $/x and $v2 =~ m[^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $]x
!ll&&!rl&&r
000
MC/DC0%0/3
$v =~ /^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $/x and $v2 =~ m[^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $]x and substr($v3, 1, 10) eq substr($v, 0, 10)
$v =~ /^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $/x $v2 =~ m[^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $]x substr($v3, 1, 10) eq substr($v, 0, 10)
Truth table0%0/4
A and B and C
A= $v =~ /^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $/xB= $v2 =~ m[^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $]xC= substr($v3, 1, 10) eq substr($v, 0, 10)
ABCresult
0XX0
10X0
1100
1111
122 and ( $v2 =~ m{^ "? \d{4}[/-]\d{2}[/-]\d{2} "? $}x )
123 and ( substr($v3,1,10) eq substr($v,0,10) )
124 ) {
125 #warn 'aaa';
126 0 return scalar 1 ;
127 }
128 else {
129 0 say 'Condition is ', $self->conditionName() ;
130 0 say 'value is ', '"'.$ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1].'"' ;
131 0 say 'expected was ', $unQuotedValue ;
132 0 return scalar 0 ;
133 }
134 }
135 }
136 else {
137 #say 'Condition ', $self->conditionName(), ' is disabled' ;
138 0 return scalar -1 ;
139 }
140 }
141  
142 sub conditionNullISExpected {
143 0 ▶ local $_ = undef ;
Subroutine conditionNullISExpected: not called CC=3 SCAR=24.8
Pod undocumented
144 0 my $self = shift ;
145 0 ▶ if ( $self->conditionNullExpected() =~ m{\A 1 \z}ix ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->conditionNullExpected =~ /\A 1 \z/xi) { } 0 0 0
elsif ($self->conditionNullExpected =~ /\A True \z/xi) { } 0 0 0
146 0 return scalar 1 ;
147 }
148 elsif ( $self->conditionNullExpected() =~ m{\A True \z}ix ) {
149 0 return scalar 1 ;
150 }
151 else {
152 0 return scalar 0 ;
153 }
154 }
155  
156 1 1 ;
157  
158 __DATA__
« lib/VSGDR/UnitTest/TestSet/Representation/NET2/VB.pm ↑ Summary lib/VSGDR/UnitTest/TestSet/Test/TestCondition.pm »