lib/VSGDR/UnitTest/TestSet/Representation.pm

filter: Statementstmt 37.8% 25 / 66 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 4 totaltotal 29.7% 33 / 111 SCAR 41.9
CC
12
Cov
28%
serialise
30.0
deserialise
20.0
make
12.0
CRAP 66.2
« lib/VSGDR/UnitTest/TestSet/Test/TestCondition.pm ↑ Summary lib/VSGDR/SQLServer/DataType/Bit.pm »
1 package VSGDR::UnitTest::TestSet::Representation;
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.02';
9  
10  
11 1 ▶use parent qw(Clone) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #TODO 1. Add support for test method attributes eg new vs2010 exceptions ala : -[ExpectedSqlException(MessageNumber = nnnnn, Severity = x, MatchFirstError = false, State = y)]
14  
15  
16 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use Data::Dumper ;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Carp ;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use vars qw($AUTOLOAD );
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 my %Types = ('XML' => 1
24 ,'NET::CS' => 1
25 ,'NET::VB' => 1
26 ,'XLS' => 1
27 ,'NET2::CS' => 1
28 ,'NET2::VB' => 1
29 ) ;
30  
31  
32 sub new {
33  
34 0 ▶ local $_ = undef ;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
35  
36 0 my $invocant = shift ;
37 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
38  
39 0 my @elems = @_ ;
40 0 my $self = bless {}, $class ;
41
42 0 $self->_init(@elems) ;
43 0 return $self ;
44 }
45  
46  
47 sub _init {
48  
49 0 ▶ local $_ = undef ;
Subroutine _init: not called CC=2 SCAR=17.9
50  
51 0 my $self = shift ;
52 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
53  
54 0 return ;
55
56 }
57  
58  
59 sub make {
60  
61 0 ▶ local $_ = undef ;
Subroutine make: not called CC=3 SCAR=24.8
Pod undocumented
62 0 my $self = shift ;
63  
64 0 ▶ my $objectType = $_[0]->{TYPE} or croak 'No Representation type' ;
Branch: 1 branch
BranchTrueFalseTotal
my $objectType = $_[0]{"TYPE"} or croak("No Representation type") 0 0 0
65 0 ▶ croak "Invalid Representation language type " unless exists $Types{$objectType };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Types{$objectType} 0 0 0
66 0 ( my $objectTypePathFileName = ${objectType} ) =~ s{::}{/}xg ;
67 0 require "VSGDR/UnitTest/TestSet/Representation/${objectTypePathFileName}.pm";
68 0 return "VSGDR::UnitTest::TestSet::Representation::${objectType}"->new(@_) ;
69  
70 }
71  
72 ## default standard implementations of code below..............
73 ##XLS has to override them.
74 ## ======================================================
75 sub serialise {
76 0 ▶ my $self = shift or croak 'no self' ;
Subroutine serialise: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
77 0 ▶ my $file = shift or croak 'no file' ;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift() or croak("no file") 0 0 0
78 0 ▶ my $object = shift or croak 'no object';
Branch: 1 branch
BranchTrueFalseTotal
my $object = shift() or croak("no object") 0 0 0
79
80 0 my $code = $self->deparse($object);
81
82 0 my $data;
83 0 my $fh = new IO::File "> ${file}" ;
84 0 ▶ if (defined ${fh} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) { } 0 0 0
85 0 print ${fh} $code;
86 0 $fh->close;
87 }
88 else {
89 0 croak "Unable to write to ${file}.";
90 }
91 0 return ;
92 }
93 ## ======================================================
94 sub deserialise {
95  
96 0 ▶ my $self = shift or croak 'no self' ;
Subroutine deserialise: not called CC=4 SCAR=30.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or croak("no self") 0 0 0
97 0 ▶ my $file = shift or croak 'no file' ;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift() or croak("no file") 0 0 0
98 0 my $data;
99 0 my $fh = new IO::File;
100 0 ▶ if ($fh->open("< ${file}")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->open("< $file")) { } 0 0 0
101 0 { local $/ = undef ; $data = <$fh> ; }
102 0 $fh->close;
103 }
104 else {
105 0 croak "Unable to read from ${file}.";
106 }
107 0 my $object = $self->parse($data);
108 0 return ${object} ;
109 }
110 ## ======================================================
111  
112  
113 1 1 ;
114  
« lib/VSGDR/UnitTest/TestSet/Test/TestCondition.pm ↑ Summary lib/VSGDR/SQLServer/DataType/Bit.pm »