| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package VSGDR::UnitTest::TestSet::Test::TestCondition::ScalarValue; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
890
|
use 5.010; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#our \$VERSION = '1.01'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use parent qw(VSGDR::UnitTest::TestSet::Test::TestCondition) ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
|
12
|
1
|
|
|
1
|
|
89
|
*AUTOLOAD = \&VSGDR::UnitTest::TestSet::Test::TestCondition::AUTOLOAD ; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use Data::Dumper ; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
16
|
1
|
|
|
1
|
|
4
|
use Carp ; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
52
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use vars qw($AUTOLOAD %ok_field); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
844
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#TODO 1: Sort out value testing you damn fool. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Authorize constructor hash fields |
|
24
|
|
|
|
|
|
|
my %ok_params = () ; |
|
25
|
|
|
|
|
|
|
for my $attr ( qw(CONDITIONTESTACTIONNAME CONDITIONNAME CONDITIONENABLED CONDITIONEXPECTEDVALUE CONDITIONNULLEXPECTED CONDITIONRESULTSET CONDITIONROWNUMBER CONDITIONCOLUMNNUMBER) ) { $ok_params{$attr}++; } |
|
26
|
|
|
|
|
|
|
my %ok_fields = () ; |
|
27
|
|
|
|
|
|
|
my %ok_fields_type = () ; |
|
28
|
|
|
|
|
|
|
# Authorize attribute fields |
|
29
|
|
|
|
|
|
|
for my $attr ( qw(conditionTestActionName conditionName conditionEnabled conditionExpectedValue conditionResultSet conditionNullExpected conditionRowNumber conditionColumnNumber) ) { $ok_fields{$attr}++; $ok_fields_type{$attr} = 'plain'; } |
|
30
|
|
|
|
|
|
|
$ok_fields_type{conditionName} = 'quoted'; |
|
31
|
|
|
|
|
|
|
$ok_fields_type{conditionEnabled} = 'bool'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _init { |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
|
|
local $_ = undef ; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $self = shift ; |
|
38
|
0
|
|
0
|
|
|
|
my $class = ref($self) || $self ; |
|
39
|
0
|
0
|
|
|
|
|
my $ref = shift or croak "no arg"; |
|
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}} ; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
croak "bad args" |
|
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
|
|
|
0
|
0
|
|
my $self = shift; |
|
73
|
0
|
|
|
|
|
|
return 'ScalarValue' ; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub testConditionMSType { |
|
77
|
0
|
|
|
0
|
0
|
|
return 'ScalarValueCondition' ; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub check { |
|
81
|
0
|
|
|
0
|
0
|
|
local $_ = undef ; |
|
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
|
0
|
|
|
|
|
if ( $self->conditionISEnabled() ) { |
|
94
|
0
|
0
|
0
|
|
|
|
if ( not $self->conditionNullISExpected() and not defined( $ra_res->[$self->conditionResultSet()-1]->[$self->conditionRowNumber()-1]->[$self->conditionColumnNumber()-1]) ) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
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 |
|
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
|
0
|
0
|
|
|
|
if ( ( $v =~ m{^ "? \d{4}-\d{2}-\d{2} \s 00:00:00 "? $}x ) |
|
|
|
|
0
|
|
|
|
|
|
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
|
|
|
0
|
0
|
|
local $_ = undef ; |
|
144
|
0
|
|
|
|
|
|
my $self = shift ; |
|
145
|
0
|
0
|
|
|
|
|
if ( $self->conditionNullExpected() =~ m{\A 1 \z}ix ) { |
|
|
|
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 ; |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__DATA__ |