| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package VSGDR::UnitTest::TestSet; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 20831 | use 5.010; | 
|  | 1 |  |  |  |  | 4 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 20 |  | 
| 5 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 11 |  | 
|  | 1 |  |  |  |  | 45 |  | 
| 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 |  |  |  |  |  |  | our $VERSION = '1.34'; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  | 1 |  | 1587 | use autodie qw(:all); | 
|  | 1 |  |  |  |  | 31205 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 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 |  |  | 1 |  | 33856 | use VSGDR::UnitTest::TestSet::Representation ; | 
|  | 1 |  |  |  |  | 15 |  | 
|  | 1 |  |  |  |  | 67 |  | 
| 25 | 1 |  |  | 1 |  | 7 | use Data::Dumper ; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 49 |  | 
| 26 | 1 |  |  | 1 |  | 6 | use Carp ; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 58 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 1 |  |  | 1 |  | 6 | use Clone; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 56 |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 1 |  |  | 1 |  | 6 | use base qw(Clone) ; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 2351 |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | our $AUTOLOAD ; | 
| 33 |  |  |  |  |  |  | my %ok_field ; | 
| 34 |  |  |  |  |  |  | # Authorize four attribute fields | 
| 35 |  |  |  |  |  |  | { | 
| 36 |  |  |  |  |  |  | for my $attr ( qw(nameSpace className __testCleanupAction __testInitializeAction) ) { $ok_field{$attr}++; } | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub new { | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 0 |  |  | 0 | 0 |  | local $_ ; | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 0 |  |  |  |  |  | my $invocant         = shift ; | 
| 44 | 0 |  | 0 |  |  |  | my $class            = ref($invocant) || $invocant ; | 
| 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 |  |  | 0 |  |  | local $_ ; | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 0 |  |  |  |  |  | my $self                = shift ; | 
| 59 | 0 |  | 0 |  |  |  | my $class               = ref($self) || $self ; | 
| 60 | 0 | 0 |  |  |  |  | my $ref = shift or croak "no arg"; | 
| 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 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 75 |  |  |  |  |  |  |  | 
| 76 | 0 | 0 |  |  |  |  | my $self        = shift or croak 'no self'; | 
| 77 | 0 |  |  |  |  |  | my $tests ; | 
| 78 | 0 | 0 |  |  |  |  | $tests          = shift if @_; | 
| 79 |  |  |  |  |  |  | # try to break refees here | 
| 80 | 0 | 0 |  |  |  |  | if ( defined $tests ) { | 
| 81 | 0 |  |  |  |  |  | $self->{TESTS} = $tests ; | 
| 82 |  |  |  |  |  |  | } | 
| 83 | 0 |  |  |  |  |  | return $self->{TESTS} ; | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | sub actions { | 
| 87 | 0 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 88 |  |  |  |  |  |  |  | 
| 89 | 0 | 0 |  |  |  |  | my $self        = shift or croak 'no self'; | 
| 90 | 0 |  |  |  |  |  | my $actions ; | 
| 91 | 0 | 0 |  |  |  |  | $actions        = shift if @_; | 
| 92 | 0 | 0 |  |  |  |  | if ( defined $actions ) { | 
| 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 | 0 |  |  |  |  | $actions{$self->initializeAction()} = 1 if defined $self->initializeAction() ; | 
| 108 | 0 | 0 |  |  |  |  | $actions{$self->cleanupAction()}    = 1 if defined $self->cleanupAction() ; | 
| 109 | 0 |  |  |  |  |  | return \%actions ; | 
| 110 |  |  |  |  |  |  | } | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | sub initializeConditions { | 
| 114 | 0 |  |  | 0 | 0 |  | local   $_          = undef ; | 
| 115 |  |  |  |  |  |  |  | 
| 116 | 0 | 0 |  |  |  |  | my $self            = shift or croak 'no self'; | 
| 117 | 0 |  |  |  |  |  | my $conditions ; | 
| 118 | 0 | 0 |  |  |  |  | $conditions         = shift if @_; | 
| 119 | 0 | 0 |  |  |  |  | if ( defined $conditions ) { | 
| 120 | 0 |  |  |  |  |  | $self->{INITIALIZECONDITIONS} = $conditions ; | 
| 121 |  |  |  |  |  |  | } | 
| 122 | 0 |  |  |  |  |  | return $self->{INITIALIZECONDITIONS} ; | 
| 123 |  |  |  |  |  |  | } | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | sub cleanupConditions { | 
| 126 | 0 |  |  | 0 | 0 |  | local   $_          = undef ; | 
| 127 |  |  |  |  |  |  |  | 
| 128 | 0 | 0 |  |  |  |  | my $self            = shift or croak 'no self'; | 
| 129 | 0 |  |  |  |  |  | my $conditions ; | 
| 130 | 0 | 0 |  |  |  |  | $conditions         = shift if @_; | 
| 131 | 0 | 0 |  |  |  |  | if ( defined $conditions ) { | 
| 132 | 0 |  |  |  |  |  | $self->{CLEANUPCONDITIONS} = $conditions ; | 
| 133 |  |  |  |  |  |  | } | 
| 134 | 0 |  |  |  |  |  | return $self->{CLEANUPCONDITIONS} ; | 
| 135 |  |  |  |  |  |  | } | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | sub commentifyAny { | 
| 138 | 0 |  |  | 0 | 0 |  | local   $_  = undef ; | 
| 139 |  |  |  |  |  |  |  | 
| 140 | 0 |  |  |  |  |  | my $self    = shift; | 
| 141 | 0 | 0 |  |  |  |  | my $commentChars    = shift or die 'No Chars' ; | 
| 142 | 0 | 0 |  |  |  |  | my $thing   = shift or die 'No thing' ; | 
| 143 | 0 |  |  |  |  |  | return <<"EOF"; | 
| 144 |  |  |  |  |  |  | ${commentChars} | 
| 145 |  |  |  |  |  |  | ${commentChars}${thing} | 
| 146 |  |  |  |  |  |  | ${commentChars} | 
| 147 |  |  |  |  |  |  | EOF | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | sub commentifyInitializeAction { | 
| 151 | 0 |  |  | 0 | 0 |  | local   $_  = undef ; | 
| 152 |  |  |  |  |  |  |  | 
| 153 | 0 |  |  |  |  |  | my $self    = shift; | 
| 154 | 0 | 0 |  |  |  |  | my $commentChars    = shift or die 'No Chars' ; | 
| 155 | 0 |  |  |  |  |  | return <<"EOF"; | 
| 156 |  |  |  |  |  |  | ${commentChars} | 
| 157 | 0 |  |  |  |  |  | ${commentChars}@{[$self->initializeAction()]} | 
| 158 |  |  |  |  |  |  | ${commentChars} | 
| 159 |  |  |  |  |  |  | EOF | 
| 160 |  |  |  |  |  |  | } | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | sub commentifyCleanupAction { | 
| 163 | 0 |  |  | 0 | 0 |  | local   $_  = undef ; | 
| 164 |  |  |  |  |  |  |  | 
| 165 | 0 |  |  |  |  |  | my $self    = shift; | 
| 166 | 0 | 0 |  |  |  |  | my $commentChars    = shift or die 'No Chars' ; | 
| 167 | 0 |  |  |  |  |  | return <<"EOF"; | 
| 168 |  |  |  |  |  |  | ${commentChars} | 
| 169 | 0 |  |  |  |  |  | ${commentChars}@{[$self->cleanupAction()]} | 
| 170 |  |  |  |  |  |  | ${commentChars} | 
| 171 |  |  |  |  |  |  | EOF | 
| 172 |  |  |  |  |  |  | } | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | sub commentifyClassName { | 
| 175 | 0 |  |  | 0 | 0 |  | local   $_  = undef ; | 
| 176 |  |  |  |  |  |  |  | 
| 177 | 0 |  |  |  |  |  | my $self    = shift; | 
| 178 | 0 | 0 |  |  |  |  | my $commentChars    = shift or die 'No Chars' ; | 
| 179 | 0 |  |  |  |  |  | return <<"EOF"; | 
| 180 |  |  |  |  |  |  | ${commentChars} | 
| 181 | 0 |  |  |  |  |  | ${commentChars}@{[$self->className()]} | 
| 182 |  |  |  |  |  |  | ${commentChars} | 
| 183 |  |  |  |  |  |  | EOF | 
| 184 |  |  |  |  |  |  | } | 
| 185 |  |  |  |  |  |  | sub initializeAction { | 
| 186 | 0 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 187 |  |  |  |  |  |  |  | 
| 188 | 0 | 0 |  |  |  |  | my $self        = shift or croak 'no self'; | 
| 189 | 0 |  |  |  |  |  | my $action ; | 
| 190 | 0 | 0 |  |  |  |  | $action         = shift if @_; | 
| 191 | 0 | 0 |  |  |  |  | if ( defined $action ) { | 
| 192 | 0 |  |  |  |  |  | $self->__testInitializeAction($action) ; | 
| 193 |  |  |  |  |  |  | } | 
| 194 | 0 |  |  |  |  |  | return $self->__testInitializeAction() ; | 
| 195 |  |  |  |  |  |  | } | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  | sub cleanupAction { | 
| 198 | 0 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 199 |  |  |  |  |  |  |  | 
| 200 | 0 | 0 |  |  |  |  | my $self        = shift or croak 'no self'; | 
| 201 | 0 |  |  |  |  |  | my $action ; | 
| 202 | 0 | 0 |  |  |  |  | $action         = shift if @_; | 
| 203 | 0 | 0 |  |  |  |  | if ( defined $action ) { | 
| 204 | 0 |  |  |  |  |  | $self->__testCleanupAction($action) ; | 
| 205 |  |  |  |  |  |  | } | 
| 206 | 0 |  |  |  |  |  | return $self->__testCleanupAction() ; | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  | } | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | sub initializeActionLiteral { | 
| 211 | 0 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 212 |  |  |  |  |  |  |  | 
| 213 | 0 | 0 |  |  |  |  | my $self        = shift or croak 'no self'; | 
| 214 | 0 |  |  |  |  |  | return 'testInitializeAction' ; | 
| 215 |  |  |  |  |  |  | } | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | sub cleanupActionLiteral { | 
| 218 | 0 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 219 |  |  |  |  |  |  |  | 
| 220 | 0 | 0 |  |  |  |  | my $self        = shift or croak 'no self'; | 
| 221 | 0 |  |  |  |  |  | return 'testCleanupAction' ; | 
| 222 |  |  |  |  |  |  |  | 
| 223 |  |  |  |  |  |  | } | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  | sub allConditionAttributeNames { | 
| 226 | 0 |  |  | 0 | 0 |  | local   $_      = undef ; | 
| 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 |  |  | 0 | 0 |  | local   $_          = undef ; | 
| 234 |  |  |  |  |  |  |  | 
| 235 | 0 |  |  |  |  |  | my $self            = shift; | 
| 236 | 0 | 0 |  |  |  |  | my $generator_type  = shift or croak "No generator supplied" ; | 
| 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 |  |  | 0 | 0 |  | local   $_          = undef ; | 
| 243 |  |  |  |  |  |  |  | 
| 244 | 0 | 0 |  |  |  |  | my $self            = shift or croak "No self" ; | 
| 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 |  |  | 0 | 0 |  | local   $_          = undef ; | 
| 259 |  |  |  |  |  |  |  | 
| 260 | 0 |  |  |  |  |  | my $self            = shift; | 
| 261 | 0 | 0 |  |  |  |  | my $oldTestName     = shift or croak "No old Test Name supplied" ; | 
| 262 | 0 | 0 |  |  |  |  | my $newTestName     = shift or croak "No new Test Name supplied" ; | 
| 263 |  |  |  |  |  |  |  | 
| 264 | 0 |  |  |  |  |  | return ; | 
| 265 |  |  |  |  |  |  | } | 
| 266 |  |  |  |  |  |  |  | 
| 267 |  |  |  |  |  |  | sub deleteTest { | 
| 268 | 0 |  |  | 0 | 0 |  | local   $_          = undef ; | 
| 269 |  |  |  |  |  |  |  | 
| 270 | 0 |  |  |  |  |  | my $self            = shift; | 
| 271 | 0 | 0 |  |  |  |  | my $testName        = shift or croak "No Test Name supplied" ; | 
| 272 |  |  |  |  |  |  |  | 
| 273 | 0 |  |  |  |  |  | return ; | 
| 274 |  |  |  |  |  |  |  | 
| 275 |  |  |  |  |  |  | } | 
| 276 |  |  |  |  |  |  |  | 
| 277 |  |  |  |  |  |  | sub Dump { | 
| 278 | 0 |  |  | 0 | 0 |  | local   $_ = undef ; | 
| 279 |  |  |  |  |  |  |  | 
| 280 | 0 |  |  |  |  |  | warn "!\n"; | 
| 281 | 0 |  |  |  |  |  | warn Dumper @_ ; | 
| 282 | 0 |  |  |  |  |  | warn "!\n"; | 
| 283 | 0 |  |  |  |  |  | return ; | 
| 284 |  |  |  |  |  |  | } | 
| 285 |  |  |  |  |  |  |  | 
| 286 | 0 |  |  | 0 | 0 |  | sub flatten { return map { @$_}  @_ } ; | 
|  | 0 |  |  |  |  |  |  | 
| 287 |  |  |  |  |  |  |  | 
| 288 |  |  |  | 0 |  |  | sub DESTROY {} | 
| 289 |  |  |  |  |  |  |  | 
| 290 |  |  |  |  |  |  | sub AUTOLOAD { | 
| 291 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 292 | 0 |  |  |  |  |  | my $attr = $AUTOLOAD; | 
| 293 | 0 |  |  |  |  |  | $attr =~ s{.*::}{}x; | 
| 294 | 0 | 0 |  |  |  |  | return unless $attr =~ m{[^A-Z]}x;  # skip DESTROY and all-cap methods | 
| 295 | 0 | 0 |  |  |  |  | croak "invalid attribute method: ->$attr()" unless $ok_field{$attr}; | 
| 296 | 0 | 0 |  |  |  |  | $self->{uc $attr} = shift if @_; | 
| 297 | 0 |  |  |  |  |  | return $self->{uc $attr}; | 
| 298 |  |  |  |  |  |  | } | 
| 299 |  |  |  |  |  |  |  | 
| 300 |  |  |  |  |  |  | 1 ; | 
| 301 |  |  |  |  |  |  |  | 
| 302 |  |  |  |  |  |  | __DATA__ |