| 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
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant
$invocant
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
| |||||||||||||||||||||
| 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
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 65 | 0 | ▶ | croak "Invalid Representation language type " unless exists $Types{$objectType }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 77 | 0 | ▶ | my $file = shift or croak 'no file' ; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 0 | ▶ | my $object = shift or croak 'no object'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 97 | 0 | ▶ | my $file = shift or croak 'no file' ; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 98 | 0 | my $data; | |||||||||||||||||||
| 99 | 0 | my $fh = new IO::File; | |||||||||||||||||||
| 100 | 0 | ▶ | if ($fh->open("< ${file}")) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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 | |||||||||||||||||||||