« 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
| |||||||||||||||||||||
| 35 | 0 | ▶ | croak "Invalid Test Condition Type" unless exists $Types{$objectType }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant
$invocant
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 86 | 0 | ▶ | croak 'bad attribute'unless $self->ok_field($attr) ; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 94 | 0 | ▶ | croak 'bad attribute'unless $self->ok_field($attr) ; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | 0 | my $UC_ATTR = uc $attr ; | |||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 0 | ▶ | $self->{$UC_ATTR} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 132 | 0 | return $self->{$UC_ATTR}; | |||||||||||||||||||
| 133 | } | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | 1 | 1 ; | |||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | __DATA__ | ||||||||||||||||||||