| 1 | package DBIO::Test::Conformance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Shared case table runner: a driver answers every case: correctly, by refusing, or by a declared deviation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Test::More (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use mro (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use DBIO::Core (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use DBIO::Schema (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use DBIO::Exception (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use DBIO::Deploy::Base (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use DBIO::Exception::Server (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | my $COUNTER = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | my $ROW_ID = 0; # the next free key of the rows the Bind checks create; reset per case | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | my %HELD; # how many rows of a case hold a value, by source, column and value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | my %KNOWN_AREA = map { $_ => 1 } qw(DDL Diff Bind Names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | my %TABLE_VERSION = (DDL => 2, Diff => 4, Bind => 1, Names => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 51 | ▶ | sub table_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_version: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 51 | my ($class, $area) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 51 | ▶ | $area //= 'DDL'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$area //= "DDL"
MC/DC100%1/1
$area //= "DDL"
$area
Truth table100%2/2
A
A= $area
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | DBIO::Exception->throw("no table version for area '$area'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 51 | ▶ | unless exists $TABLE_VERSION{$area}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 50 | return $TABLE_VERSION{$area}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 150 | ▶ | sub cases { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cases: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 150 | my ($class, $area) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 150 | ▶ | DBIO::Exception->throw('cases() needs an area name, e.g. DDL') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $area and $area =~ /\A[A-Za-z]\w*\z/
MC/DC0%0/2
defined $area and $area =~ /\A[A-Za-z]\w*\z/
defined $area
$area =~ /\A[A-Za-z]\w*\z/
Truth table33%1/3
A and B
A= defined $areaB= $area =~ /\A[A-Za-z]\w*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | unless defined $area and $area =~ /\A[A-Za-z]\w*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 150 | my $module = "DBIO::Test::Conformance::Cases::$area"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 150 | (my $file = "$module.pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 150 | my $loaded = eval { require $file; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 150 | ▶ | DBIO::Exception->throw("no conformance case list for area '$area': $module does not load") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | unless $loaded; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 150 | return $module->cases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # ---------------------------------------------------------------- the seams | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | ▶ | sub _unprovided { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unprovided: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | my ($class, $seam) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 7 | ▶ | $class = ref($class) || $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 7 | DBIO::Exception->throw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | "$class->$seam must be provided by the driver (see DBIO::Test::Conformance)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | sub conformance_live_available { $_[0]->_unprovided('conformance_live_available') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_live_available: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | sub conformance_connect { $_[0]->_unprovided('conformance_connect') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_connect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | sub conformance_install { $_[0]->_unprovided('conformance_install') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_install: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub conformance_cleanup { $_[0]->_unprovided('conformance_cleanup') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_cleanup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub conformance_fact { $_[0]->_unprovided('conformance_fact') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_fact: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | sub conformance_diff_is_empty { $_[0]->_unprovided('conformance_diff_is_empty') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_diff_is_empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | sub conformance_upgrade { $_[0]->_unprovided('conformance_upgrade') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_upgrade: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | sub conformance_deploy { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_deploy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub conformance_apply_name { $_[0]->_unprovided('conformance_apply_name') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_apply_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 18 | ▶ | sub conformance_name_kinds { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_name_kinds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 330 | ▶ | sub conformance_namespace { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_namespace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 143 | ▶ | sub conformance_quote_ident { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_quote_ident: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 143 | my ($class, $schema, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 143 | my $quote = $schema->storage->sql_maker->quote_char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 143 | ▶ | return $name unless defined $quote and length(ref $quote ? join '', @$quote : $quote); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $quote and length(ref $quote ? join("", @$quote) : $quote)
MC/DC50%1/2
defined $quote and length(ref $quote ? join("", @$quote) : $quote)
defined $quote
length(ref $quote ? join("", @$quote) : $quote)
Truth table66%2/3
A and B
A= defined $quoteB= length(ref $quote ? join("", @$quote) : $quote)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 140 | ▶ | my ($open, $close) = ref $quote ? @$quote : ($quote, $quote); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 140 | (my $inner = $name) =~ s/\Q$close\E/$close$close/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 140 | return $open . $inner . $close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 20 | ▶ | sub conformance_refusals { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_refusals: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 20 | ▶ | sub conformance_refused_areas { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_refused_areas: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 10 | ▶ | sub conformance_answered_through { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_answered_through: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | ▶ | sub conformance_create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_create: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 8 | my ($class, $schema, $source, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | ▶ | my $row = $schema->resultset($source)->create({ %{ $values || {} } }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$values || {}
MC/DC0%0/1
$values || {}
$values
Truth table50%1/2
A
A= $values
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | $row->discard_changes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 8 | return { $row->get_columns }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | sub conformance_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_count: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | my ($class, $schema, $source, $cond) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | return $schema->resultset($source)->search($cond || {})->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cond || {}
MC/DC0%0/1
$cond || {}
$cond
Truth table50%1/2
A
A= $cond
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | sub conformance_delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_delete: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | my ($class, $schema, $source, $cond) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | return $schema->resultset($source)->search($cond || {})->delete({ all => !$cond }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cond || {}
MC/DC0%0/1
$cond || {}
$cond
Truth table50%1/2
A
A= $cond
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | sub conformance_find { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_find: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | my ($class, $schema, $source, $cond) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | my $row = $schema->resultset($source)->search($cond || {})->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cond || {}
MC/DC0%0/1
$cond || {}
$cond
Truth table50%1/2
A
A= $cond
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | return undef unless $row; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | return { $row->get_columns }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | sub conformance_update { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_update: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 1 | my ($class, $schema, $source, $cond, $set) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | return $schema->resultset($source)->search($cond || {})->update($set, { all => !$cond }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cond || {}
MC/DC0%0/1
$cond || {}
$cond
Truth table50%1/2
A
A= $cond
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | sub conformance_populate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conformance_populate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my ($class, $schema, $source, $rows) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | $schema->resultset($source)->populate($rows); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # ---------------------------------------------------- declarations, offline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 30 | ▶ | sub check_declarations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_declarations: called CC=16 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 30 | my ($class, $area) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 30 | my %known = map { $_->{name} => 1 } @{ $class->cases($area) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 30 | my @problem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 28 | ▶ | my $check = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 28 | my ($label, $decl, $cases) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 28 | ▶ | return "$label: not a hash" unless ref $decl eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 27 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 27 | ▶ | my $kind = $decl->{kind} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$decl->{"kind"} // ""
MC/DC0%0/1
$decl->{"kind"} // ""
$decl->{"kind"}
Truth table50%1/2
A
A= $decl->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 27 | ▶ | if ($kind eq 'deviation' and !$cases) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$kind eq "deviation" and not $cases
MC/DC100%2/2
$kind eq "deviation" and not $cases
$kind eq "deviation"
not $cases
Truth table100%3/3
A and not(B)
A= $kind eq "deviation"B= not $cases
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | return "$label: kind must be 'server' or 'pending', not 'deviation'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 26 | ▶ | if ($kind eq 'deviation') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | push @p, "$label: a deviation needs a fact (qr//) naming what the server does" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | unless ref $decl->{fact} eq 'Regexp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | push @p, "$label: a deviation needs a reason, the text of why it is accepted" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | unless defined $decl->{reason} and !ref $decl->{reason} and length $decl->{reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $decl->{"reason"} and not ref $decl->{"reason"} and length $decl->{"reason"}
defined $decl->{"reason"} and not ref $decl->{"reason"}
MC/DC33%1/3
defined $decl->{"reason"} and not ref $decl->{"reason"} and length $decl->{"reason"}
defined $decl->{"reason"}
not ref $decl->{"reason"}
length $decl->{"reason"}
Truth table50%2/4
A and not(B) and C
A= defined $decl->{"reason"}B= not ref $decl->{"reason"}C= length $decl->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | return @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 22 | ▶ | push @p, "$label: kind must be 'server' or 'pending', not '$kind'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$kind eq "server" or $kind eq "pending"
MC/DC100%2/2
$kind eq "server" or $kind eq "pending"
$kind eq "server"
$kind eq "pending"
Truth table100%3/3
A or B
A= $kind eq "server"B= $kind eq "pending"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | unless $kind eq 'server' or $kind eq 'pending'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | push @p, "$label: reason must be a regex (qr//)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 22 | ▶ | unless ref $decl->{reason} eq 'Regexp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 22 | return @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 30 | my $refusals = $class->conformance_refusals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 30 | for my $name (sort keys %$refusals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 29 | ▶ | next unless _area_of_case_name($name) eq $area; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 24 | ▶ | push @problem, "refusal '$name': unknown case" unless $known{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 24 | ▶ | push @problem, "refusal '$name': a Names case takes no refusal declaration (a refusal is one of its answers)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | if $area eq 'Names'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 24 | push @problem, $check->("refusal '$name'", $refusals->{$name}, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 30 | my $areas = $class->conformance_refused_areas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 30 | for my $name (sort keys %$areas) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | push @problem, "refused area $name: unknown area" unless $KNOWN_AREA{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | ▶ | push @problem, "refused area $name: the Names list is answered per kind by conformance_name_kinds" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | if $name eq 'Names'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 4 | push @problem, $check->("refused area $name", $areas->{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 30 | my $through = $class->conformance_answered_through; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 30 | ▶ | if (ref $through eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 14 | for my $name (sort keys %$through) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | push @problem, "conformance_answered_through: unknown area $name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 37 | ▶ | unless $KNOWN_AREA{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | push @problem, "conformance_answered_through for $name must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 37 | ▶ | unless defined $through->{$name} and $through->{$name} =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $through->{$name} and $through->{$name} =~ /\A[0-9]+\z/
MC/DC50%1/2
defined $through->{$name} and $through->{$name} =~ /\A[0-9]+\z/
defined $through->{$name}
$through->{$name} =~ /\A[0-9]+\z/
Truth table66%2/3
A and B
A= defined $through->{$name}B= $through->{$name} =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 16 | ▶ | push @problem, 'conformance_answered_through must be a non-negative integer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $through and not ref $through and $through =~ /\A[0-9]+\z/
defined $through and not ref $through
MC/DC66%2/3
defined $through and not ref $through and $through =~ /\A[0-9]+\z/
defined $through
not ref $through
$through =~ /\A[0-9]+\z/
Truth table75%3/4
A and not(B) and C
A= defined $throughB= not ref $throughC= $through =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | unless defined $through and !ref $through and $through =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 30 | return @problem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # the area a case name belongs to, by its prefix; a name with none of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # prefixes is checked with DDL, which reports it as an unknown case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 29 | ▶ | sub _area_of_case_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_area_of_case_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 29 | my ($name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 29 | ▶ | return 'Diff' if $name =~ /\Adiff-/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 21 | ▶ | return 'Bind' if $name =~ /\Abind-/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 21 | ▶ | return 'Names' if $name =~ /\Aname-/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 20 | return 'DDL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # the version of an area's list a driver declared it answered through: a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # scalar counts for DDL only, a hash ref per area, a missing area is 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 116 | ▶ | sub _through_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_through_for: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 116 | my ($class, $area) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 116 | my $through = $class->conformance_answered_through; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 116 | ▶ | return ref $through eq 'HASH' ? ($through->{$area} // 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$through->{$area} // 0
MC/DC100%1/1
$through->{$area} // 0
$through->{$area}
Truth table100%2/2
A
A= $through->{$area}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | : $area eq 'DDL' ? $through | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # ------------------------------------------------------------ the run itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 116 | ▶ | sub results { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
results: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 116 | my ($class, $area, %opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 116 | my @cases = @{ $class->cases($area) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 116 | ▶ | if (my $only = $opt{only}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 94 | my %want = map { $_ => 1 } @$only; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 94 | @cases = grep { $want{ $_->{name} } } @cases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 116 | my $refusals = $class->conformance_refusals; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 116 | my $through = $class->_through_for($area); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 116 | ▶ | my $strict = $ENV{AUTHOR_TESTING} || $ENV{RELEASE_TESTING}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ENV{'AUTHOR_TESTING'} || $ENV{'RELEASE_TESTING'}
MC/DC100%2/2
$ENV{'AUTHOR_TESTING'} || $ENV{'RELEASE_TESTING'}
$ENV{'AUTHOR_TESTING'}
$ENV{'RELEASE_TESTING'}
Truth table100%3/3
A || B
A= $ENV{'AUTHOR_TESTING'}B= $ENV{'RELEASE_TESTING'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 116 | my $areas = $class->conformance_refused_areas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 116 | my $diff_refused = exists $areas->{Diff}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # a refused area is a refusal of every case of the list, of the declared kind | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 116 | ▶ | my $area_refusal = $area ne 'DDL' ? $areas->{$area} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 116 | my @results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 116 | for my $case (@cases) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 495 | my $own = $refusals->{ $case->{name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 495 | ▶ | my $result = $area eq 'Names' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$own // $area_refusal
MC/DC100%2/2
$own // $area_refusal
$own
$area_refusal
Truth table100%3/3
A // B
A= $ownB= $area_refusal
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ? $class->_run_names_case($case) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | : $class->_run_case($area, $case, $own // $area_refusal, $diff_refused); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # a refusal that came from the declared area, not from the case itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | $result->{via_area} = $area | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 495 | ▶ | if !$own and $area_refusal and ($result->{status} eq 'pending' or $result->{status} eq 'refused'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
not $own and $area_refusal and $result->{"status"} eq "pending" || $result->{"status"} eq "refused"
not $own and $area_refusal
$result->{"status"} eq "pending" or $result->{"status"} eq "refused"
MC/DC100%4/4
not $own and $area_refusal and $result->{"status"} eq "pending" || $result->{"status"} eq "refused"
not $own
$area_refusal
$result->{"status"} eq "pending"
$result->{"status"} eq "refused"
Truth table100%5/5
not(A) and B and C or D
A= not $ownB= $area_refusalC= $result->{"status"} eq "pending"D= $result->{"status"} eq "refused"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 495 | ▶ | $result->{reason} = $area_refusal->{reason} if $result->{via_area}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 495 | ▶ | if ($result->{status} eq 'fail' and $case->{since} > $through and !$strict) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$result->{"status"} eq "fail" and $case->{"since"} > $through and not $strict
$result->{"status"} eq "fail" and $case->{"since"} > $through
MC/DC100%3/3
$result->{"status"} eq "fail" and $case->{"since"} > $through and not $strict
$result->{"status"} eq "fail"
$case->{"since"} > $through
not $strict
Truth table100%4/4
A and B and not(C)
A= $result->{"status"} eq "fail"B= $case->{"since"} > $throughC= not $strict
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 30 | $result->{status} = 'todo'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 30 | $result->{message} = "newer than answered_through $through: $result->{message}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 495 | push @results, $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 116 | return @results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 11 | ▶ | sub summary_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
summary_line: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 11 | my ($class, $results) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 11 | my (%area_cases, @area_order); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 11 | for my $r (grep { $_->{via_area} } @$results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 56 | ▶ | push @area_order, $r->{via_area} unless $area_cases{ $r->{via_area} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 56 | push @{ $area_cases{ $r->{via_area} } }, $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 11 | ▶ | my @pending = grep { $_->{status} eq 'pending' and !$_->{via_area} } @$results; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$_->{'status'} eq 'pending' && !$_->{'via_area'}
MC/DC100%2/2
$_->{'status'} eq 'pending' && !$_->{'via_area'}
$_->{'status'} eq 'pending'
!$_->{'via_area'}
Truth table100%3/3
A && not(B)
A= $_->{'status'} eq 'pending'B= !$_->{'via_area'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 11 | my @todo = grep { $_->{status} eq 'todo' } @$results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 11 | my @dev = grep { $_->{status} eq 'deviation' } @$results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 11 | my @part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 11 | for my $area (@area_order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | my @cases = @{ $area_cases{$area} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 3 | my $first = $cases[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | my $n = scalar @cases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | ▶ | my $count = $n . ' case' . ($n == 1 ? '' : 's'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | if ($first->{status} eq 'pending') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | push @part, "$area area pending: $count"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | my $reason = ref $first->{reason} eq 'Regexp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | ▶ | ? (re::regexp_pattern($first->{reason}))[0] : $first->{reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 1 | push @part, "$area area refused by the server ($reason): $count"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | push @part, scalar(@pending) . ' pending refusal' . (@pending == 1 ? '' : 's') . ': ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 11 | ▶ | . join(', ', map { $_->{case} } @pending) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | if @pending; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | push @part, scalar(@dev) . ' deviation' . (@dev == 1 ? '' : 's') . ': ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 11 | ▶ | . join(', ', map { "$_->{case} ($_->{reason})" } @dev) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | if @dev; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | push @part, scalar(@todo) . ' case' . (@todo == 1 ? '' : 's') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | . ' newer than the answered table version: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 11 | ▶ | . join(', ', map { $_->{case} } @todo) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | if @todo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 11 | ▶ | return @part ? join('; ', @part) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 5 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=7 SCAR=20.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | my ($class, $area) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 5 | my $tb = Test::More->builder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | my @problem = $class->check_declarations($area); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | ▶ | Test::More::ok(!@problem, 'the conformance declarations are whole') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | or Test::More::diag(join "\n", @problem); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | ▶ | unless ($class->conformance_live_available) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 2 | Test::More::diag(scalar(@{ $class->cases($area) }) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | . ' cases not run: no server to run against'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | my @results = $class->results($area); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | for my $r (@results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 53 | my $label = "$r->{case}: $r->{status}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 53 | ▶ | if ($r->{status} eq 'todo') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $tb->todo_start($r->{message}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | Test::More::ok(0, $label); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $tb->todo_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | elsif ($r->{status} eq 'fail') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | Test::More::ok(0, $label); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | Test::More::diag("$r->{case}: $r->{message}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 53 | Test::More::ok(1, $label); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 3 | my $line = $class->summary_line(\@results); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 3 | ▶ | Test::More::diag($line) if defined $line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # A Names case (ADR 0077): the driver sets the name through its identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # quoting and shows the same name back, or refuses with a DBIO::Exception. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # server's own error, or another name, is a failure; so is any exception | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # that is not a DBIO::Exception. A kind the driver does not declare is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # applicable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 164 | ▶ | sub _run_names_case { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_names_case: called CC=13 SCAR=26.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 164 | my ($class, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 164 | my ($kind, $name) = @{ $case->{input} }{qw(kind name)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 164 | my %r = (case => $case->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | return { %r, status => 'na', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | message => "the driver declares no $kind (conformance_name_kinds)" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 164 | ▶ | unless $class->conformance_name_kinds->{$kind}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # the missing seam is the driver's programming error, never a refusal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 98 | ▶ | return { %r, status => 'fail', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | message => (ref($class) || $class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | . '->conformance_apply_name must be provided by the driver (see DBIO::Test::Conformance)' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | if $class->can('conformance_apply_name') == \&DBIO::Test::Conformance::conformance_apply_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 97 | my $shown; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 97 | my $ok = eval { $shown = $class->conformance_apply_name($kind, $name); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 97 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 51 | ▶ | my $error = $@ || 'unknown error'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$@ || 'unknown error'
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 51 | my $text = "$error"; $text =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 51 | ▶ | return { %r, status => 'fail', message => "the database answered, not the driver: $text" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($error) and $error->isa("DBIO::Exception::Server")
MC/DC50%1/2
builtin::blessed($error) and $error->isa("DBIO::Exception::Server")
builtin::blessed($error)
$error->isa("DBIO::Exception::Server")
Truth table66%2/3
A and B
A= builtin::blessed($error)B= $error->isa("DBIO::Exception::Server")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | if Scalar::Util::blessed($error) and $error->isa('DBIO::Exception::Server'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 15 | ▶ | return { %r, status => 'refused', message => $text } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($error) and $error->isa("DBIO::Exception")
MC/DC0%0/2
builtin::blessed($error) and $error->isa("DBIO::Exception")
builtin::blessed($error)
$error->isa("DBIO::Exception")
Truth table33%1/3
A and B
A= builtin::blessed($error)B= $error->isa("DBIO::Exception")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | if Scalar::Util::blessed($error) and $error->isa('DBIO::Exception'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return { %r, status => 'fail', message => "not a DBIO::Exception: $text" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 46 | ▶ | return { %r, status => 'fail', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $shown and $shown eq $name
MC/DC50%1/2
defined $shown and $shown eq $name
defined $shown
$shown eq $name
Truth table66%2/3
A and B
A= defined $shownB= $shown eq $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | message => "the $kind was set, but introspection shows " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | . (defined $shown ? _show($shown) : 'nothing') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | . ' for ' . _show($name) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | unless defined $shown and $shown eq $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 31 | return { %r, status => 'pass', message => '' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # One case: drive it, then turn what happened into one answer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 331 | ▶ | sub _run_case { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_case: called CC=18 SCAR=29.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 331 | my ($class, $area, $case, $refusal, $diff_refused) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 331 | my $name = $case->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 331 | my $state = { errors => [], cleanup_error => undef }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 331 | my $ok = eval { $class->_drive($area, $case, $state, $diff_refused); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 331 | ▶ | my $exception = $ok ? undef : ($@ || 'unknown error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$@ or "unknown error"
MC/DC0%0/1
$@ or "unknown error"
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 331 | my %r = (case => $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 331 | ▶ | if (defined $state->{cleanup_error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return { %r, status => 'fail', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | message => "cleanup failed: $state->{cleanup_error}" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | return { %r, status => 'na', message => $state->{na} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 331 | ▶ | if defined $state->{na} and !defined $exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $state->{"na"} and not defined $exception
MC/DC50%1/2
defined $state->{"na"} and not defined $exception
defined $state->{"na"}
not defined $exception
Truth table66%2/3
A and not(B)
A= defined $state->{"na"}B= not defined $exception
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 328 | ▶ | if ($refusal and $refusal->{kind} eq 'deviation') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$refusal and $refusal->{"kind"} eq "deviation"
MC/DC100%2/2
$refusal and $refusal->{"kind"} eq "deviation"
$refusal
$refusal->{"kind"} eq "deviation"
Truth table100%3/3
A and B
A= $refusalB= $refusal->{"kind"} eq "deviation"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 6 | ▶ | if (defined $exception) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | my $text = "$exception"; $text =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | return { %r, status => 'fail', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | message => "an exception is not a deviation: $text" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 5 | ▶ | unless (@{ $state->{errors} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | return { %r, status => 'fail', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | message => "stale deviation: declared ($refusal->{reason}) but the case runs correctly" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | my $seen = join '; ', @{ $state->{errors} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | return { %r, status => 'fail', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | message => "the result does not match the declared fact $refusal->{fact}: $seen" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 4 | ▶ | unless $seen =~ $refusal->{fact}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | return { %r, status => 'deviation', message => $seen, reason => $refusal->{reason} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 322 | ▶ | if (defined $exception) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 141 | ▶ | unless ($refusal) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 14 | return { %r, status => 'fail', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | message => "unexpected exception, and no refusal is declared for this case: $exception" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 127 | my @missing = $class->_refusal_problems($case, $refusal, $exception); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 127 | ▶ | return { %r, status => 'fail', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | message => 'the refusal does not meet the convention: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | . join('; ', @missing) . " -- got: $exception" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | if @missing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 118 | ▶ | my $status = $refusal->{kind} eq 'pending' ? 'pending' : 'refused'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 118 | my $text = "$exception"; $text =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 118 | return { %r, status => $status, message => $text }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 181 | ▶ | if ($refusal) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | return { %r, status => 'fail', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | message => "stale refusal: declared $refusal->{kind}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 5 | . ' but the case succeeded' . (@{ $state->{errors} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | ? ' with wrong results: ' . join('; ', @{ $state->{errors} }) : '') }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 176 | ▶ | if (@{ $state->{errors} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 40 | return { %r, status => 'fail', message => join('; ', @{ $state->{errors} }) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 136 | return { %r, status => 'pass', message => '' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 331 | ▶ | sub _drive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_drive: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 331 | my ($class, $area, $case, $state, $diff_refused) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 331 | $ROW_ID = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 331 | %HELD = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 331 | ▶ | return $class->_drive_diff($case, $state) if $area eq 'Diff'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 157 | my $schema_class = $class->_build_schema_class($case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 157 | my $schema = $class->conformance_connect($schema_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 157 | my $namespace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 157 | my $namespace_given = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 157 | my $ran = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 157 | $class->_resolve_view_definitions($schema, $case->{input}{sources}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 157 | $namespace = $class->conformance_namespace($schema, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 156 | $namespace_given = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 156 | $class->conformance_install($schema, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 123 | for my $expect (@{ $case->{expect} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 191 | my $error = $class->_check($schema, $case, $expect); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 191 | ▶ | push @{ $state->{errors} }, $error if defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | # postcondition 1 belongs to the install list; a value is not a declaration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 123 | ▶ | if ($area eq 'DDL' and !@{ $state->{errors} } and !$diff_refused | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$area eq "DDL" and not @{$state->{"errors"};} and not $diff_refused and not $class->conformance_diff_is_empty($schema, $case)
$area eq "DDL" and not @{$state->{"errors"};} and not $diff_refused
$area eq "DDL" and not @{$state->{"errors"};}
MC/DC100%4/4
$area eq "DDL" and not @{$state->{"errors"};} and not $diff_refused and not $class->conformance_diff_is_empty($schema, $case)
$area eq "DDL"
not @{$state->{"errors"};}
not $diff_refused
not $class->conformance_diff_is_empty($schema, $case)
Truth table100%5/5
A and not(B) and not(C) and not(D)
A= $area eq "DDL"B= not @{$state->{"errors"};}C= not $diff_refusedD= not $class->conformance_diff_is_empty($schema, $case)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | and !$class->conformance_diff_is_empty($schema, $case)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | push @{ $state->{errors} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 'diff: installing the declaration and diffing against the same declaration is not empty'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 123 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 157 | ▶ | my $failure = $ran ? undef : ($@ || 'unknown error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$@ or "unknown error"
MC/DC0%0/1
$@ or "unknown error"
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 157 | ▶ | if ($namespace_given) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 156 | my $cleaned = eval { $class->conformance_cleanup($schema, $case, $namespace); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 156 | ▶ | $state->{cleanup_error} = ($@ || 'unknown error') unless $cleaned; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'unknown error'
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # no mark, nothing to remove; cleanup also disconnects, so close here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | eval { $schema->storage->disconnect }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 157 | ▶ | die $failure if defined $failure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 123 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # A Diff case: install `from`, load the rows, hand the driver the unconnected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # class of `to` and let it upgrade; the expectations and the second | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # postcondition are asked of the schema it returns. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 174 | ▶ | sub _drive_diff { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_drive_diff: called CC=24 SCAR=32.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 174 | my ($class, $case, $state) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 174 | my $input = $case->{input}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 174 | my $from = $class->conformance_connect($class->_build_schema_class($case, $input->{from})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 174 | my $schema = $from; # the connected schema the case works with right now | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 174 | my $namespace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 174 | my $namespace_given = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 174 | my $ran = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 174 | $class->_resolve_view_definitions($from, $input->{from}{sources}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 174 | $namespace = $class->conformance_namespace($from, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 174 | $namespace_given = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 174 | $class->conformance_install($from, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 174 | ▶ | for my $row (@{ $input->{rows} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$input->{'rows'} || []
MC/DC0%0/1
$input->{'rows'} || []
$input->{'rows'}
Truth table50%1/2
A
A= $input->{'rows'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 235 | $class->conformance_create($from, $row->{source}, $row->{values}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 174 | ▶ | my $quote = sub { $class->conformance_quote_ident($from, $_[0]) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 174 | my $to_class = $class->_build_schema_class($case, $input->{to}, $quote); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 174 | my $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 174 | ▶ | if ($input->{deploy}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 28 | my $deploy = $class->conformance_deploy($from, $to_class, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 16 | ▶ | unless (defined $deploy) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 3 | $state->{na} = 'the driver provides no conformance_deploy'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 13 | ▶ | DBIO::Exception->throw((ref($class) || $class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition58%7/12
builtin::blessed($deploy) and $deploy->isa("DBIO::Deploy::Base") and builtin::blessed($deploy->schema) and $deploy->schema->isa("DBIO::Schema")
builtin::blessed($deploy) and $deploy->isa("DBIO::Deploy::Base") and builtin::blessed($deploy->schema)
builtin::blessed($deploy) and $deploy->isa("DBIO::Deploy::Base")
ref $class || $class
MC/DC25%1/4
builtin::blessed($deploy) and $deploy->isa("DBIO::Deploy::Base") and builtin::blessed($deploy->schema) and $deploy->schema->isa("DBIO::Schema")
builtin::blessed($deploy)
$deploy->isa("DBIO::Deploy::Base")
builtin::blessed($deploy->schema)
$deploy->schema->isa("DBIO::Schema")
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table40%2/5
A and B and C and D
A= builtin::blessed($deploy)B= $deploy->isa("DBIO::Deploy::Base")C= builtin::blessed($deploy->schema)D= $deploy->schema->isa("DBIO::Schema")
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | . '->conformance_deploy must return a DBIO::Deploy::Base over the connected target schema') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | unless Scalar::Util::blessed($deploy) and $deploy->isa('DBIO::Deploy::Base') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | and Scalar::Util::blessed($deploy->schema) and $deploy->schema->isa('DBIO::Schema'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 12 | $to = $deploy->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 12 | $schema = $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 12 | $class->_run_deploy_check($input->{deploy}, $deploy, $case, $state); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 146 | $to = $class->conformance_upgrade($from, $to_class, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 61 | ▶ | DBIO::Exception->throw((ref($class) || $class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
builtin::blessed($to) and $to->isa("DBIO::Schema")
ref $class || $class
MC/DC50%1/2
builtin::blessed($to) and $to->isa("DBIO::Schema")
builtin::blessed($to)
$to->isa("DBIO::Schema")
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table66%2/3
A and B
A= builtin::blessed($to)B= $to->isa("DBIO::Schema")
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | . '->conformance_upgrade must return the connected schema of the target declaration') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | unless Scalar::Util::blessed($to) and $to->isa('DBIO::Schema'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 60 | $schema = $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 72 | for my $expect (@{ $case->{expect} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 220 | my $error = $class->_check($schema, $case, $expect); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 211 | ▶ | push @{ $state->{errors} }, $error if defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 63 | ▶ | if (!@{ $state->{errors} } and !$class->conformance_diff_is_empty($schema, $case)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@{$state->{"errors"};} or $class->conformance_diff_is_empty($schema, $case)
MC/DC100%2/2
@{$state->{"errors"};} or $class->conformance_diff_is_empty($schema, $case)
@{$state->{"errors"};}
$class->conformance_diff_is_empty($schema, $case)
Truth table100%3/3
A or B
A= @{$state->{"errors"};}B= $class->conformance_diff_is_empty($schema, $case)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | push @{ $state->{errors} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 'diff: after the upgrade, a diff against the target declaration is not empty'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 63 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 174 | ▶ | my $failure = $ran ? undef : ($@ || 'unknown error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$@ or "unknown error"
MC/DC0%0/1
$@ or "unknown error"
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 174 | ▶ | if ($namespace_given) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 174 | my $cleaned = eval { $class->conformance_cleanup($schema, $case, $namespace); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 174 | ▶ | $state->{cleanup_error} = ($@ || 'unknown error') unless $cleaned; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'unknown error'
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | eval { $schema->storage->disconnect }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | # the schema the upgrade started from is closed last: it may share its handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 174 | ▶ | eval { $from->storage->disconnect } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | if Scalar::Util::refaddr($schema) != Scalar::Util::refaddr($from); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 174 | ▶ | die $failure if defined $failure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 66 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # The deploy cases of the Diff list: what the deploy object of the driver does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # with a diff. Problems go to $state->{errors}; the database is brought to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # target declaration in the end, so the shared postconditions hold. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 12 | ▶ | sub _run_deploy_check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_deploy_check: called CC=16 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 12 | my ($class, $decl, $deploy, $case, $state) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 12 | my $check = $decl->{check}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 12 | my $schema = $deploy->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 12 | ▶ | my $err = sub { push @{ $state->{errors} }, @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 8 | ▶ | my $unchanged = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 8 | my ($what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 8 | ▶ | for my $expect (@{ $decl->{unchanged} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$decl->{'unchanged'} || []
MC/DC0%0/1
$decl->{'unchanged'} || []
$decl->{'unchanged'}
Truth table50%1/2
A
A= $decl->{'unchanged'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 12 | my $e = $class->_check($schema, $case, $expect); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 12 | ▶ | $err->("$what, but $e") if defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 12 | ▶ | if ($check eq 'inherited') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 4 | my $ref = ref $deploy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 4 | for my $m (qw(apply upgrade)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 8 | my $own = $ref->can($m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 8 | ▶ | $err->("$ref does not inherit $m from DBIO::Deploy::Base; a driver takes part through " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$own and $own == "DBIO::Deploy::Base"->can($m)
MC/DC50%1/2
$own and $own == "DBIO::Deploy::Base"->can($m)
$own
$own == "DBIO::Deploy::Base"->can($m)
Truth table66%2/3
A and B
A= $ownB= $own == "DBIO::Deploy::Base"->can($m)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | . '_check_before_apply and _execute_diff') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | unless $own and $own == DBIO::Deploy::Base->can($m); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 4 | $deploy->upgrade; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | elsif ($check eq 'dry_run') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 4 | my $diff = $deploy->diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 4 | ▶ | $err->('the diff of the case has no changes') unless $diff->has_changes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 4 | my $seen = $deploy->apply($diff, dry_run => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 4 | ▶ | $err->('apply with dry_run did not return the diff') unless $seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 4 | $unchanged->('apply with dry_run ran something'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | $deploy->upgrade; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | elsif ($check eq 'guard') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 4 | my $diff = $deploy->diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 4 | ▶ | my $thrown = eval { $deploy->apply($diff); 1 } ? undef : ($@ || 'unknown error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$@ or "unknown error"
MC/DC0%0/1
$@ or "unknown error"
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 4 | ▶ | if (!defined $thrown) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | $err->('apply of a destructive diff without allow_destructive did not throw'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | ▶ | elsif (!(Scalar::Util::blessed($thrown) and $thrown->isa('DBIO::Exception')) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
not builtin::blessed($thrown) && $thrown->isa("DBIO::Exception") or $thrown->isa("DBIO::Exception::Server")
builtin::blessed($thrown) && $thrown->isa('DBIO::Exception')
MC/DC0%0/3
not builtin::blessed($thrown) && $thrown->isa("DBIO::Exception") or $thrown->isa("DBIO::Exception::Server")
builtin::blessed($thrown)
$thrown->isa('DBIO::Exception')
$thrown->isa("DBIO::Exception::Server")
Truth table25%1/4
not(A && B) or C
A= builtin::blessed($thrown)B= $thrown->isa('DBIO::Exception')C= $thrown->isa("DBIO::Exception::Server")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | or $thrown->isa('DBIO::Exception::Server')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $err->("apply of a destructive diff without allow_destructive threw something other than a DBIO::Exception: $thrown"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | elsif ("$thrown" !~ /allow_destructive/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $err->("the refusal does not name allow_destructive: $thrown"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 4 | $unchanged->('apply without allow_destructive ran a statement'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 4 | $deploy->apply($deploy->diff, allow_destructive => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | DBIO::Exception->throw("case $case->{name}: unknown deploy check '$check'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # the {{identifier}} places of a view definition are resolved once the storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # exists: the hook quotes them by the rule of the driver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 331 | ▶ | sub _resolve_view_definitions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_view_definitions: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 331 | my ($class, $schema, $sources) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 331 | ▶ | my $quote = sub { $class->conformance_quote_ident($schema, $_[0]) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 331 | for my $def (@$sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 450 | ▶ | my $view = $def->{view} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 32 | (my $sql = $view->{definition}) =~ s/\{\{(.+?)\}\}/$quote->($1)/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 32 | $schema->source($def->{name})->view_definition($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 331 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 127 | ▶ | sub _refusal_problems { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refusal_problems: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 127 | my ($class, $case, $refusal, $exception) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 127 | ▶ | return 'it is not a DBIO::Exception' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($exception) and $exception->isa("DBIO::Exception")
MC/DC50%1/2
builtin::blessed($exception) and $exception->isa("DBIO::Exception")
builtin::blessed($exception)
$exception->isa("DBIO::Exception")
Truth table66%2/3
A and B
A= builtin::blessed($exception)B= $exception->isa("DBIO::Exception")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | unless Scalar::Util::blessed($exception) and $exception->isa('DBIO::Exception'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 126 | ▶ | return 'it is a DBIO::Exception::Server: a server error handed through is not a refusal' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | if $exception->isa('DBIO::Exception::Server'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 125 | my $text = "$exception"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 125 | ▶ | my $subject = $case->{subject} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$case->{'subject'} || {}
MC/DC0%0/1
$case->{'subject'} || {}
$case->{'subject'}
Truth table50%1/2
A
A= $case->{'subject'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 125 | my @sources = $class->_case_sources($case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 125 | ▶ | my $src = $subject->{source} // $sources[0]{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$subject->{"source"} // $sources[0]{"name"}
MC/DC0%0/2
$subject->{"source"} // $sources[0]{"name"}
$subject->{"source"}
$sources[0]{"name"}
Truth table33%1/3
A // B
A= $subject->{"source"}B= $sources[0]{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 125 | my ($def) = grep { $_->{name} eq $src } @sources; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 125 | my $table = $def->{table}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 125 | my @missing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 125 | ▶ | push @missing, "the text does not contain the stem 'refus'" unless $text =~ /refus/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 125 | ▶ | push @missing, "the text does not name the table '$table'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $table and index($text, $table) != -1
MC/DC50%1/2
defined $table and index($text, $table) != -1
defined $table
index($text, $table) != -1
Truth table66%2/3
A and B
A= defined $tableB= index($text, $table) != -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | unless defined $table and index($text, $table) >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | push @missing, "the text does not name the column '$subject->{column}'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | if defined $subject->{column} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 125 | ▶ | and $text !~ /(?<![A-Za-z0-9_\$])\Q$subject->{column}\E(?![A-Za-z0-9_\$])/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $subject->{"column"} and not $text =~ /(?<![A-Za-z0-9_\$])\Q$subject->{"column"}\E(?![A-Za-z0-9_\$])/
MC/DC100%2/2
defined $subject->{"column"} and not $text =~ /(?<![A-Za-z0-9_\$])\Q$subject->{"column"}\E(?![A-Za-z0-9_\$])/
defined $subject->{"column"}
not $text =~ /(?<![A-Za-z0-9_\$])\Q$subject->{"column"}\E(?![A-Za-z0-9_\$])/
Truth table100%3/3
A and not(B)
A= defined $subject->{"column"}B= not $text =~ /(?<![A-Za-z0-9_\$])\Q$subject->{"column"}\E(?![A-Za-z0-9_\$])/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | push @missing, "the text does not match the declared reason $refusal->{reason}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 125 | ▶ | unless $text =~ $refusal->{reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 125 | return @missing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # ------------------------------------------------- building a case's classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # every source declaration of a case, the target declaration of a Diff case first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 141 | ▶ | sub _case_sources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_case_sources: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 141 | my ($class, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 141 | my $input = $case->{input}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 141 | ▶ | return @{ $input->{sources} } if $input->{sources}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 112 | return map { @{ $input->{$_}{sources} } } qw(to from); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # the table of a source moniker, for a source the schema no longer knows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 16 | ▶ | sub _table_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_of: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 16 | my ($class, $case, $moniker) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 16 | my ($def) = grep { $_->{name} eq $moniker } $class->_case_sources($case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 16 | ▶ | DBIO::Exception->throw("case $case->{name}: no source '$moniker'") unless $def; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 16 | return $def->{table}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | # $decl is the declaration to build: the case's input, or the from / to of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # Diff case; $quote, when given, resolves the {{name}} of a view definition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # right away (a class that is connected only later has no storage to ask) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 562 | ▶ | sub _build_schema_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_schema_class: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 562 | my ($class, $case, $decl, $quote) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 562 | ▶ | $decl //= $case->{input}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$decl //= $case->{"input"}
MC/DC0%0/2
$decl //= $case->{"input"}
$decl
$case->{"input"}
Truth table66%2/3
A //= B
A= $declB= $case->{"input"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 562 | my $base = 'DBIO::Test::Conformance::_Case' . ++$COUNTER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 562 | my $schema_class = "$base\::Schema"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 1336 | ▶ | my $derive = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 1336 | my ($pkg, $parent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 1336 | @{"${pkg}::ISA"} = ($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 1336 | mro::set_mro($pkg, 'c3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 562 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 562 | $derive->($schema_class, 'DBIO::Schema'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 562 | my %package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 562 | my @sources = @{ $decl->{sources} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 562 | for my $def (@sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 774 | my $pkg = $package{ $def->{name} } = "$base\::Result::$def->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 774 | $derive->($pkg, 'DBIO::Core'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 774 | ▶ | $pkg->table_class('DBIO::ResultSource::View') if $def->{view}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 774 | $pkg->table($def->{table}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 774 | ▶ | if (my $view = $def->{view}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 57 | my $rsrc = $pkg->result_source_instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 57 | ▶ | $rsrc->is_virtual($view->{virtual} ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 57 | my $sql = $view->{definition}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 57 | ▶ | $sql =~ s/\{\{(.+?)\}\}/$quote->($1)/ge if $quote; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 57 | $rsrc->view_definition($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 774 | $pkg->add_columns(@{ $def->{columns} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 774 | ▶ | $pkg->set_primary_key(@{ $def->{primary_key} }) if $def->{primary_key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 774 | ▶ | $pkg->add_unique_constraint(@$_) for @{ $def->{unique} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$def->{'unique'} || []
MC/DC100%1/1
$def->{'unique'} || []
$def->{'unique'}
Truth table100%2/2
A
A= $def->{'unique'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | $pkg->result_source_instance->add_index_declaration($_) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 774 | ▶ | for @{ $def->{indexes} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$def->{'indexes'} || []
MC/DC100%1/1
$def->{'indexes'} || []
$def->{'indexes'}
Truth table100%2/2
A
A= $def->{'indexes'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # relationships after every package exists: they name each other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 562 | for my $def (@sources) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 774 | my $pkg = $package{ $def->{name} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 774 | ▶ | for my $rel (@{ $def->{relationships} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$def->{'relationships'} || []
MC/DC100%1/1
$def->{'relationships'} || []
$def->{'relationships'}
Truth table100%2/2
A
A= $def->{'relationships'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 100 | my $type = $rel->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | $pkg->$type($rel->{name}, $package{ $rel->{source} }, $rel->{cond}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 100 | ▶ | $rel->{attrs} || ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$rel->{'attrs'} || ()
MC/DC0%0/2
$rel->{'attrs'} || ()
$rel->{'attrs'}
()
Truth table66%2/3
A || B
A= $rel->{'attrs'}B= ()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 562 | $schema_class->register_class($_->{name}, $package{ $_->{name} }) for @sources; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 562 | return $schema_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # ------------------------------------------------------ the expectation kinds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 8 | my %CHECK = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | read_back => '_check_read_back', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | rejects => '_check_rejects', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | search_by => '_check_search_by', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | auto_key => '_check_auto_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | cascade_delete => '_check_cascade_delete', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | fact => '_check_fact', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | rows_kept => '_check_rows_kept', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | count => '_check_count', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | bind_roundtrip => '_check_bind_roundtrip', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | bind_lob_ops => '_check_bind_lob_ops', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | bind_literal => '_check_bind_literal', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 2 | ▶ | sub expectation_kinds { sort keys %CHECK } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expectation_kinds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 423 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 423 | my ($class, $schema, $case, $expect) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 423 | my ($kind, $args) = %$expect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 423 | ▶ | my $method = $CHECK{$kind} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | or DBIO::Exception->throw("case $case->{name}: unknown expectation kind '$kind'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 423 | return $class->$method($schema, $args, $case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 192 | ▶ | sub _show { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_show: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 192 | my ($v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 192 | ▶ | return 'NULL' unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 186 | ▶ | return '[' . join(', ', map { _show($_) } @$v) . ']' if ref $v eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 176 | return "'$v'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 903 | ▶ | sub _same { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_same: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 903 | my ($got, $want) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 903 | ▶ | return 1 if !defined $got and !defined $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $got or defined $want
MC/DC100%2/2
defined $got or defined $want
defined $got
defined $want
Truth table100%3/3
A or B
A= defined $gotB= defined $want
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 854 | ▶ | return 0 if !defined $got or !defined $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $got and defined $want
MC/DC100%2/2
defined $got and defined $want
defined $got
defined $want
Truth table100%3/3
A and B
A= defined $gotB= defined $want
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 834 | ▶ | if (ref $want eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 43 | ▶ | return 0 unless ref $got eq 'ARRAY' and @$got == @$want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $got eq "ARRAY" and @$got == @$want
MC/DC50%1/2
ref $got eq "ARRAY" and @$got == @$want
ref $got eq "ARRAY"
@$got == @$want
Truth table66%2/3
A and B
A= ref $got eq "ARRAY"B= @$got == @$want
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 38 | ▶ | for my $i (0 .. $#$want) { return 0 unless _same($got->[$i], $want->[$i]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 38 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 791 | ▶ | return 0 if ref $got; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 791 | ▶ | return $got eq $want ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 49 | ▶ | sub _check_read_back { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_read_back: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 49 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 49 | my $row = $class->conformance_create($schema, $a->{source}, $a->{create}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 41 | my @bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 41 | ▶ | for my $col (sort keys %{ $a->{is} || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$a->{'is'} || {}
MC/DC100%1/1
$a->{'is'} || {}
$a->{'is'}
Truth table100%2/2
A
A= $a->{'is'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | push @bad, "$a->{source}.$col: expected " . _show($a->{is}{$col}) . ", read back " . _show($row->{$col}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 39 | ▶ | unless _same($row->{$col}, $a->{is}{$col}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 41 | ▶ | for my $col (sort keys %{ $a->{isnt} || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$a->{'isnt'} || {}
MC/DC100%1/1
$a->{'isnt'} || {}
$a->{'isnt'}
Truth table100%2/2
A
A= $a->{'isnt'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | push @bad, "$a->{source}.$col: read back " . _show($row->{$col}) . ", which it must not be" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 6 | ▶ | if _same($row->{$col}, $a->{isnt}{$col}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 41 | ▶ | for my $col (sort keys %{ $a->{like} || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$a->{'like'} || {}
MC/DC100%1/1
$a->{'like'} || {}
$a->{'like'}
Truth table100%2/2
A
A= $a->{'like'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | push @bad, "$a->{source}.$col: read back " . _show($row->{$col}) . ", expected to match $a->{like}{$col}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 6 | ▶ | unless defined $row->{$col} and $row->{$col} =~ $a->{like}{$col}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $row->{$col} and $row->{$col} =~ /$a->{"like"}{$col}/
MC/DC0%0/2
defined $row->{$col} and $row->{$col} =~ /$a->{"like"}{$col}/
defined $row->{$col}
$row->{$col} =~ /$a->{"like"}{$col}/
Truth table33%1/3
A and B
A= defined $row->{$col}B= $row->{$col} =~ /$a->{"like"}{$col}/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 41 | ▶ | return @bad ? join('; ', @bad) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 35 | ▶ | sub _check_rejects { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_rejects: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 35 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 35 | ▶ | $class->conformance_create($schema, $a->{source}, $a->{first}) if $a->{first}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 35 | my $accepted = eval { $class->conformance_create($schema, $a->{source}, $a->{create}); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 35 | ▶ | return "$a->{source}: the server accepted a row it must reject" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | if $accepted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 29 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | # conformance_count, with an undef answer turned into a failure text: a count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | # that returns nothing is a broken seam, never a number to compare | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 201 | ▶ | sub _counted { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_counted: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 201 | my ($class, $schema, $source, $cond) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 201 | my $n = $class->conformance_count($schema, $source, $cond); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 200 | ▶ | return (undef, "conformance_count returned undef for $source") unless defined $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 199 | return ($n, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 17 | ▶ | sub _check_search_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_search_by: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 17 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 17 | $class->conformance_create($schema, $a->{source}, $a->{create}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 17 | ▶ | my $through = $a->{through} // $a->{source}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$a->{"through"} // $a->{"source"}
MC/DC0%0/2
$a->{"through"} // $a->{"source"}
$a->{"through"}
$a->{"source"}
Truth table66%2/3
A // B
A= $a->{"through"}B= $a->{"source"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 17 | my ($found, $bad) = $class->_counted($schema, $through, { $a->{column} => $a->{value} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 16 | ▶ | return $bad if defined $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 15 | ▶ | return "$through.$a->{column}: " . _show($a->{value}) . " found $found rows, expected 1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | unless $found == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 15 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 4 | ▶ | sub _check_auto_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_auto_key: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 4 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 4 | ▶ | my $row = $class->conformance_create($schema, $a->{source}, $a->{create} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$a->{'create'} || {}
MC/DC0%0/1
$a->{'create'} || {}
$a->{'create'}
Truth table50%1/2
A
A= $a->{'create'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 4 | my @pk = $schema->source($a->{source})->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 4 | ▶ | my @unset = grep { !defined $row->{$_} or $row->{$_} eq '' } @pk; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
!defined($row->{$_}) || $row->{$_} eq ''
MC/DC0%0/2
!defined($row->{$_}) || $row->{$_} eq ''
!defined($row->{$_})
$row->{$_} eq ''
Truth table33%1/3
not(A) || B
A= !defined($row->{$_})B= $row->{$_} eq ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 4 | ▶ | return "$a->{source}: the key " . join(', ', @unset) . ' was not set by the server' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | if @unset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 9 | ▶ | sub _check_cascade_delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_cascade_delete: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 9 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 9 | my $parent = $class->conformance_create($schema, $a->{parent}, $a->{parent_values}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 9 | ▶ | my %child = %{ $a->{child_values} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$a->{'child_values'} || {}
MC/DC0%0/1
$a->{'child_values'} || {}
$a->{'child_values'}
Truth table50%1/2
A
A= $a->{'child_values'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 9 | my %link; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 9 | for my $ccol (keys %{ $a->{link} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 9 | $child{$ccol} = $link{$ccol} = $parent->{ $a->{link}{$ccol} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 9 | $class->conformance_create($schema, $a->{child}, \%child); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 9 | my %pk = map { $_ => $parent->{$_} } $schema->source($a->{parent})->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 9 | $class->conformance_delete($schema, $a->{parent}, \%pk); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 9 | my ($left, $bad) = $class->_counted($schema, $a->{child}, \%link); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 9 | ▶ | return $bad if defined $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 9 | ▶ | return "$a->{child}: $left rows remain after the parent was deleted, expected cascade" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | if $left; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 6 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 164 | ▶ | sub _check_fact { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_fact: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 164 | my ($class, $schema, $a, $case) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 164 | my %args = %$a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 164 | my $name = delete $args{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 164 | my $want = delete $args{is}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # a source the upgrade dropped is no longer in the schema: its table is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | # one the case declared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 251 | $args{table} = (grep { $_ eq $a->{source} } $schema->sources) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | ? $schema->source($a->{source})->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 164 | ▶ | : $class->_table_of($case, $a->{source}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 164 | my $got = $class->conformance_fact($schema, $name, \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 164 | ▶ | if ($name eq 'column_names') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 37 | ▶ | $got = [ sort @$got ] if ref $got eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 37 | $want = [ sort @$want ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 164 | my $on = join '.', grep { defined } @$a{qw(source column)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 164 | ▶ | return "$name of $on: expected " . _show($want) . ', the server shows ' . _show($got) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | unless _same($got, $want); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 139 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 74 | ▶ | sub _check_rows_kept { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_rows_kept: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 74 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 74 | my $find = $a->{find}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 74 | my $what = "$a->{source} row (" . join(', ', map { "$_ = " . _show($find->{$_}) } sort keys %$find) . ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 74 | my $row = $class->conformance_find($schema, $a->{source}, $find); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 74 | ▶ | return "$what: gone after the upgrade" unless $row; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 72 | my @bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 72 | ▶ | for my $col (sort keys %{ $a->{is} || {} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$a->{'is'} || {}
MC/DC100%1/1
$a->{'is'} || {}
$a->{'is'}
Truth table100%2/2
A
A= $a->{'is'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 57 | my $error = _compare($row->{$col}, $a->{is}{$col}, "$what, $col after the upgrade"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 57 | ▶ | push @bad, $error if defined $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 72 | ▶ | return @bad ? join('; ', @bad) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | sub _check_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_count: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | my ($n, $bad) = $class->_counted($schema, $a->{source}, $a->{where} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$a->{'where'} || {}
MC/DC0%0/1
$a->{'where'} || {}
$a->{'where'}
Truth table0%0/2
A
A= $a->{'where'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | return $bad if defined $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | return "$a->{source}: $n rows match, expected $a->{is}" unless $n == $a->{is}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | # a value for a message: short and plain as it is, else its length and start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 109 | ▶ | sub _describe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_describe: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 109 | my ($v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 109 | ▶ | return 'NULL' unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 97 | ▶ | return "'$v'" if length($v) <= 24 and $v =~ /\A[\x20-\x7e]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $v <= 24 and $v =~ /\A[\x20-\x7e]*\z/
MC/DC50%1/2
length $v <= 24 and $v =~ /\A[\x20-\x7e]*\z/
length $v <= 24
$v =~ /\A[\x20-\x7e]*\z/
Truth table66%2/3
A and B
A= length $v <= 24B= $v =~ /\A[\x20-\x7e]*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | return length($v) . ' characters starting ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 30 | . join(' ', map { sprintf '%02x', ord } split //, substr($v, 0, 6)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | # undef when got and want are the same string, else the failure text; for a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | # long value it says where they part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 543 | ▶ | sub _compare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 543 | my ($got, $want, $what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 543 | ▶ | return undef if _same($got, $want); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 34 | my $text = "$what: expected " . _describe($want) . ', read back ' . _describe($got); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 34 | ▶ | if (defined $got and defined $want and !ref $got) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $got and defined $want and not ref $got
defined $got and defined $want
MC/DC66%2/3
defined $got and defined $want and not ref $got
defined $got
defined $want
not ref $got
Truth table75%3/4
A and B and not(C)
A= defined $gotB= defined $wantC= not ref $got
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 22 | ▶ | my $n = length($got) < length($want) ? length($got) : length($want); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 22 | my $at = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 22 | ▶ | $at++ while $at < $n and substr($got, $at, 1) eq substr($want, $at, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$at < $n and substr($got, $at, 1) eq substr($want, $at, 1)
MC/DC100%2/2
$at < $n and substr($got, $at, 1) eq substr($want, $at, 1)
$at < $n
substr($got, $at, 1) eq substr($want, $at, 1)
Truth table100%3/3
A and B
A= $at < $nB= substr($got, $at, 1) eq substr($want, $at, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 22 | $text .= " (first difference at position $at)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 34 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # --------------------------------------------------------- the Bind checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 59 | ▶ | sub _check_bind_roundtrip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_bind_roundtrip: called CC=18 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 59 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 59 | my ($src, $col) = @$a{qw(source column)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 59 | my ($pk) = $schema->source($src)->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 59 | my @bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 59 | ▶ | my $push = sub { push @bad, $_[0] if defined $_[0] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 59 | for my $v (@{ $a->{values} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 173 | for my $op (@{ $a->{ops} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 664 | my $what = "$src.$col $op"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 664 | my $held_key = join "\0", $src, $col, $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 664 | ▶ | if ($op eq 'int_first') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | # a statement that binds an integer, before the value is bound | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 12 | my (undef, $bad) = $class->_counted($schema, $src, { $pk => 0 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 12 | ▶ | push @bad, "$what: $bad" if defined $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | elsif ($op eq 'create') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 173 | my $row = $class->conformance_create($schema, $src, { $pk => ++$ROW_ID, $col => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 173 | $push->(_compare($row->{$col}, $v, $what)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 173 | $HELD{$held_key}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | elsif ($op eq 'find') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 153 | my $row = $class->conformance_find($schema, $src, { $col => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 153 | ▶ | if ($row) { $push->(_compare($row->{$col}, $v, $what)) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 17 | else { push @bad, "$what: no row found by " . _describe($v) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | elsif ($op eq 'search') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 153 | my ($n, $bad) = $class->_counted($schema, $src, { $col => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | if (defined $bad) { push @bad, "$what: $bad"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | push @bad, "$what: " . _describe($v) . " found $n rows, expected " . ($HELD{$held_key} // 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 153 | ▶ | unless $n == ($HELD{$held_key} // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$HELD{$held_key} // 0
$HELD{$held_key} // 0
MC/DC0%0/1
$HELD{$held_key} // 0
$HELD{$held_key}
MC/DC0%0/1
$HELD{$held_key} // 0
$HELD{$held_key}
Truth table50%1/2
A
A= $HELD{$held_key}
Truth table50%1/2
A
A= $HELD{$held_key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | ▶ | elsif ($op eq 'update' or $op eq 'populate') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$op eq "update" or $op eq "populate"
MC/DC0%0/2
$op eq "update" or $op eq "populate"
$op eq "update"
$op eq "populate"
Truth table33%1/3
A or B
A= $op eq "update"B= $op eq "populate"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 173 | my $key = ++$ROW_ID; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 173 | ▶ | if ($op eq 'update') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 173 | $class->conformance_create($schema, $src, { $pk => $key }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 173 | $class->conformance_update($schema, $src, { $pk => $key }, { $col => $v }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $class->conformance_populate($schema, $src, [ { $pk => $key, $col => $v } ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 173 | my $row = $class->conformance_find($schema, $src, { $pk => $key }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 173 | ▶ | if ($row) { $push->(_compare($row->{$col}, $v, $what)) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | else { push @bad, "$what: the row $key is not there" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 173 | $HELD{$held_key}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | DBIO::Exception->throw("bind_roundtrip: unknown operation '$op'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 59 | ▶ | return @bad ? join('; ', @bad) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 7 | ▶ | sub _check_bind_lob_ops { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_bind_lob_ops: called CC=11 SCAR=25.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 7 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 7 | my ($src, $col, $label) = @$a{qw(source column label_column)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 7 | my ($pk) = $schema->source($src)->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 7 | my $value = $a->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 7 | my @bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | # create({}): the row exists and the LOB is empty (NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 7 | my $empty = $class->conformance_create($schema, $src, {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | push @bad, "$src.$col create({}): read back " . _describe($empty->{$col}) . ', expected NULL' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 7 | ▶ | if defined $empty->{$col}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # update of the LOB alone; the caller's hash keeps the value, not a placeholder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 7 | my %set = ($col => $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 7 | $class->conformance_update($schema, $src, { $pk => $empty->{$pk} }, \%set); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | push @bad, _compare($set{$col}, $value, "$src.$col update: the caller's hash") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 7 | ▶ | if !_same($set{$col}, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 7 | my $row = $class->conformance_find($schema, $src, { $pk => $empty->{$pk} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | push @bad, _compare($row && $row->{$col}, $value, "$src.$col update of the LOB only") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 7 | ▶ | if !$row or !_same($row->{$col}, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$row and _same($row->{$col}, $value)
$row && $row->{$col}
MC/DC0%0/2
$row and _same($row->{$col}, $value)
$row
_same($row->{$col}, $value)
MC/DC0%0/2
$row && $row->{$col}
$row
$row->{$col}
Truth table33%1/3
A and B
A= $rowB= _same($row->{$col}, $value)
Truth table0%0/3
A && B
A= $rowB= $row->{$col}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | # populate mixing NULL and values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 7 | my @want = ( [ 'lob-a', undef ], [ 'lob-b', $value ], [ 'lob-c', undef ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 7 | my @rows = map { +{ $label => $_->[0], $col => $_->[1] } } @want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 7 | $class->conformance_populate($schema, $src, \@rows); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 7 | for my $i (0 .. $#want) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | push @bad, _compare($rows[$i]{$col}, $want[$i][1], "$src.$col populate: the caller's row $i") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 21 | ▶ | if !_same($rows[$i]{$col}, $want[$i][1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 21 | my $got = $class->conformance_find($schema, $src, { $label => $want[$i][0] }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | ▶ | if (!$got) { push @bad, "$src populate: row '$want[$i][0]' is not there"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | push @bad, _compare($got->{$col}, $want[$i][1], "$src.$col populate row '$want[$i][0]'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 21 | ▶ | if !_same($got->{$col}, $want[$i][1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 7 | ▶ | return @bad ? join('; ', @bad) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 5 | ▶ | sub _check_bind_literal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_bind_literal: called CC=8 SCAR=21.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 5 | my ($class, $schema, $a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 5 | my ($src, $col) = @$a{qw(source column)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 5 | (my $sql = $a->{literal}) =~ s/\{\{(.+?)\}\}/$class->conformance_quote_ident($schema, $1)/ge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 5 | $class->conformance_create($schema, $src, $a->{create}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 5 | my @bad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 5 | my ($hit, $hit_bad) = $class->_counted($schema, $src, \[ $sql, $a->{value} ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 5 | ▶ | push @bad, "$src.$col literal SQL: $hit_bad" if defined $hit_bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 5 | ▶ | push @bad, "$src.$col literal SQL: the bind " . _describe($a->{value}) . " found $hit rows, expected 1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $hit_bad and $hit != 1
MC/DC50%1/2
not defined $hit_bad and $hit != 1
not defined $hit_bad
$hit != 1
Truth table66%2/3
not(A) and B
A= not defined $hit_badB= $hit != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | if !defined $hit_bad and $hit != 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 5 | my ($miss, $miss_bad) = $class->_counted($schema, $src, \[ $sql, $a->{other} ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 5 | ▶ | push @bad, "$src.$col literal SQL: $miss_bad" if defined $miss_bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 5 | ▶ | push @bad, "$src.$col literal SQL: the bind " . _describe($a->{other}) . " found $miss rows, expected 0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $miss_bad and $miss != 0
MC/DC0%0/2
not defined $miss_bad and $miss != 0
not defined $miss_bad
$miss != 0
Truth table33%1/3
not(A) and B
A= not defined $miss_badB= $miss != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | if !defined $miss_bad and $miss != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 5 | ▶ | return @bad ? join('; ', @bad) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||