| 1 | package Test::Inter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2010-2024 Sullivan Beck. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | require 5.004; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 16 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 16 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 16 | ▶ | use Cwd 'abs_path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 16 | our($VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 16 | $VERSION='1.13'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # BASE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | return $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 16 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 16 | my($class,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 16 | my($name,%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 16 | ▶ | if (@args % 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 15 | ($name,%opts) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | $name = $0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | $name =~ s,^\./,,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | %opts = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # The basic structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 16 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'name' => $name, # the name of the test script | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'start' => 1, # the first test to run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'end' => 0, # the last test to end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 'plan' => 0, # the number of tests planned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'abort' => 0, # abort on the first failed test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'quiet' => 0, # if 1, no output on successes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # (this should only be done when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # running as an interactive script) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'mode' => 'test', # mode to run script in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'width' => 80, # width of terminal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'features' => {}, # a list of available features | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'use_lib' => 'on', # whether to run 'use lib' when loading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # this module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'skipall' => '', # the reason for skipping all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # remaining tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'plandone' => 0, # 1 if a plan is done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'testsrun' => 0, # 1 if any tests have been run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 'libdir' => '', # a directory to load modules from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 'testdir' => '', # the test directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 16 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 16 | $main::TI_NUM = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # Handle options, environment variables, global variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 16 | my @opts = qw(start end testnum plan abort quiet mode width skip_all); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 16 | my %o = map { $_,1 } @opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 16 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 16 | foreach my $opt (@opts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 144 | my $OPT = uc("ti_$opt"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 144 | my $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 144 | ▶ | if (defined ${ "main::$OPT" }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | $val = ${ "main::$OPT" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } elsif (exists $ENV{$OPT}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $val = $ENV{$OPT}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } elsif (exists $opts{$opt}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | $val = $opts{$opt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 135 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 9 | &{ "Test::Inter::$opt" }($self,$val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # uncoverable branch true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 16 | ▶ | if ($$self{'mode'} ne 'test') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | print "\nRunning $name...\n"; # uncoverable statement | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # We assume that the module is distributed in a directory with the correct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # hierarchy. This is: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # /some/path MODDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # /t TESTDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # /lib LIBDIR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # We'll find the full path to each. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 16 | my($moddir,$testdir,$libdir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # uncoverable branch false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # uncoverable branch true count:2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # uncoverable branch false count:2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # uncoverable branch true count:3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # uncoverable branch false count:3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 16 | ▶ | if (-f "$0") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 16 | $moddir = dirname(dirname(abs_path($0))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } elsif (-d "./t") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $moddir = dirname(abs_path('.')); # uncoverable statement | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } elsif (-d "../t") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $moddir = dirname(abs_path('..')); # uncoverable statement | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # uncoverable branch false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 16 | ▶ | if (-d "$moddir/t") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 16 | $testdir = "$moddir/t"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # uncoverable branch false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 16 | ▶ | if (-d "$moddir/lib") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 16 | $libdir = "$moddir/lib"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 16 | $$self{'moddir'} = $moddir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 16 | $$self{'testdir'} = $testdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 16 | $$self{'libdir'} = $libdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 16 | $self->use_lib(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 16 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 16 | ▶ | sub use_lib { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_lib: called CC=5 SCAR=16.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 16 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 16 | ▶ | if (defined $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $$self{'use_lib'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | ▶ | if ($$self{'use_lib'} eq 'on') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | foreach my $dir ($$self{'libdir'},$$self{'testdir'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 32 | ▶ | next if (! defined $dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 16 | ▶ | eval "use lib '$dir'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub testdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
testdir: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my($self,$req) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if ($req && $req eq 'mod') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$req and $req eq "mod"
MC/DC0%0/2
$req and $req eq "mod"
$req
$req eq "mod"
Truth table0%0/3
A and B
A= $reqB= $req eq "mod"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return $$self{'moddir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ▶ | } elsif ($req && $req eq 'lib') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$req and $req eq "lib"
MC/DC0%0/2
$req and $req eq "lib"
$req
$req eq "lib"
Truth table0%0/3
A and B
A= $reqB= $req eq "lib"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return $$self{'libdir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | return $$self{'testdir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | $val = 1 if (! defined($val)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | ▶ | $self->_die("start requires an integer value") if ($val !~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | $$self{'start'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | ▶ | sub end { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | ▶ | $val = 0 if (! $val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | ▶ | $self->_die("end requires an integer value") if ($val !~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | $$self{'end'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | sub testnum { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
testnum: called CC=3 SCAR=12.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | if (! defined($val)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $$self{'start'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $$self{'end'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | $self->_die("testnum requires an integer value") if ($val !~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $$self{'start'} = $$self{'end'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub plan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($$self{'plandone'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->_die('Plan/done_testing included twice'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $$self{'plandone'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $val = 0 if (! defined($val)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $self->_die("plan requires an integer value") if ($val !~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $$self{'plan'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ($val != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->_plan($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 14 | ▶ | sub done_testing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done_testing: called CC=5 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 14 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 14 | ▶ | if ($$self{'plandone'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->_die('Plan/done_testing included twice'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 14 | $$self{'plandone'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 14 | ▶ | $val = $main::TI_NUM if (! $val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 14 | ▶ | $self->_die("done_testing requires an integer value") if ($val !~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 14 | $self->_plan($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 14 | ▶ | if ($val != $main::TI_NUM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->_die("Ran $main::TI_NUM tests, expected $val"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub abort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abort: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $val = 0 if (! $val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $$self{'abort'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub quiet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quiet: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | $val = 0 if (! $val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $$self{'quiet'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mode: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | $val = 'test' if (! $val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $$self{'mode'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub width { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
width: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $val = 0 if (! $val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $$self{'width'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | sub skip_all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip_all: called CC=11 SCAR=40.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | my($self,$reason,@features) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | if (@features) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $skip = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | foreach my $feature (@features) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (! exists $$self{'features'}{$feature} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"features"}{$feature} and $self->{"features"}{$feature}
MC/DC0%0/2
exists $self->{"features"}{$feature} and $self->{"features"}{$feature}
exists $self->{"features"}{$feature}
$self->{"features"}{$feature}
Truth table0%0/3
A and B
A= exists $self->{"features"}{$feature}B= $self->{"features"}{$feature}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ! $$self{'features'}{$feature}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $skip = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $reason = "Required feature ($feature) missing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | if (! $reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | return if (! $skip); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | ▶ | if ($$self{'plandone'} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"plandone"} or $self->{"testsrun"}
MC/DC0%0/2
$self->{"plandone"} or $self->{"testsrun"}
$self->{"plandone"}
$self->{"testsrun"}
Truth table33%1/3
A or B
A= $self->{"plandone"}B= $self->{"testsrun"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | $$self{'testsrun'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $reason = 'Remaining tests skipped' if (! $reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $$self{'skipall'} = $reason; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | ▶ | $reason = 'Test script skipped' if (! $reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | $self->_plan(0,$reason); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub _die { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_die: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my($self,$message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | print "ERROR: $message\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | sub feature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
feature: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 4 | my($self,$feature,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | $$self{'features'}{$feature} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub diag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my($self,$message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | return if ($$self{'quiet'} == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $self->_diag($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub note { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my($self,$message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return if ($$self{'quiet'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->_diag($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # LOAD METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # The routines were originally from Test::More (though they have been | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # changed... some to a greater extent than others). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 6 | ▶ | sub require_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_ok: called CC=21 SCAR=33.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | my($self,$module,$mode) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | ▶ | $mode = '' if (! $mode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 6 | ▶ | $main::TI_NUM++ unless ($mode eq 'feature'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 6 | my $pack = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 12 | my @inc = map { "unshift(\@INC,'$_');\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | ($$self{'libdir'},$$self{'testdir'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 6 | my($desc,$code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 6 | ▶ | if ( $module =~ /^\d+(?:\.\d+)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # A perl version check. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | $desc = "require perl $module"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | $code = <<REQUIRE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | require $module; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | REQUIRE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 4 | ▶ | $module = qq['$module'] unless $self->_is_module_name($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 4 | $desc = "require $module"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # So the following do not get picked up by cpantorpm-depreq or other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # tools that try to determine dependencies and prereqs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 4 | my $p = "package"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 4 | my $r = "require"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 4 | $code = <<REQUIRE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | $p $pack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | @inc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $r $module; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | REQUIRE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 6 | ▶ | $desc .= ' (should not load)' if ($mode eq 'forbid'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | ▶ | $desc .= ' (feature)' if ($mode eq 'feature'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | my($eval_result,$eval_error) = $self->_eval($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 6 | chomp($eval_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 6 | my @eval_error = split(/\n/,$eval_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 6 | foreach my $err (@eval_error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | $err =~ s/ \(\@INC contains.*//; # strip out the actual @INC values | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 6 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 6 | ▶ | if ($eval_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # Able to load the module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 3 | ▶ | if ($mode eq 'forbid') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $$self{'skipall'} = 'Loaded a module not supposed to be present'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $self->_not_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | $self->_diag('Test required that module not be loadable') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | unless ($$self{'quiet'} == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } elsif ($mode eq 'feature') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | $self->feature($module,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | ▶ | if (! $$self{'quiet'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | $self->_diag($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | $self->_diag("Feature available: $module"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | $self->_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # Unable to load the module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | ▶ | if ($mode eq 'forbid') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | $self->_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } elsif ($mode eq 'feature') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | $self->feature($module,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | if (! $$self{'quiet'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | $self->_diag($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | $self->_diag("Feature unavailable: $module"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $$self{'skipall'} = 'Unable to load a required module'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->_not_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | if ( ($ok && $$self{'quiet'}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 6 | ▶ | (! $ok && $$self{'quiet'} == 2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok and $self->{"quiet"}
not $ok and $self->{"quiet"} == 2
MC/DC0%0/4
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok
$self->{"quiet"}
not $ok
$self->{"quiet"} == 2
Truth table14%1/7
A and B or not(C) and D
A= $okB= $self->{"quiet"}C= not $okD= $self->{"quiet"} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 6 | foreach my $err (@eval_error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 3 | $self->_diag($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 12 | ▶ | sub use_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_ok: called CC=27 SCAR=35.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 12 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 12 | my $mode = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 12 | ▶ | if ($args[$#args] eq 'forbid' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args[$#args] eq "forbid" or $args[$#args] eq "feature"
MC/DC100%2/2
$args[$#args] eq "forbid" or $args[$#args] eq "feature"
$args[$#args] eq "forbid"
$args[$#args] eq "feature"
Truth table100%3/3
A or B
A= $args[$#args] eq "forbid"B= $args[$#args] eq "feature"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | $args[$#args] eq 'feature') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 7 | $mode = pop(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 12 | ▶ | $main::TI_NUM++ unless ($mode eq 'feature'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 12 | my $pack = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 12 | my($code,$desc,$module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 12 | ▶ | if ( @args == 1 and $args[0] =~ /^\d+(?:\.\d+)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
@args == 1 and $args[0] =~ /^\d+(?:\.\d+)?$/
MC/DC100%2/2
@args == 1 and $args[0] =~ /^\d+(?:\.\d+)?$/
@args == 1
$args[0] =~ /^\d+(?:\.\d+)?$/
Truth table100%3/3
A and B
A= @args == 1B= $args[0] =~ /^\d+(?:\.\d+)?$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | # A perl version check. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | $desc = "require perl $args[0]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | $module = 'perl'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 3 | $code = <<USE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | use $args[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | USE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } elsif (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 9 | $module = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 9 | ▶ | if (! $self->_is_module_name($module)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $self->_not_ok("use module: invalid module name: $module"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 9 | my $vers = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 9 | ▶ | if ( @args and $args[0] =~ /^\d+(?:\.\d+)?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@args and $args[0] =~ /^\d+(?:\.\d+)?$/
MC/DC100%2/2
@args and $args[0] =~ /^\d+(?:\.\d+)?$/
@args
$args[0] =~ /^\d+(?:\.\d+)?$/
Truth table100%3/3
A and B
A= @argsB= $args[0] =~ /^\d+(?:\.\d+)?$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | $vers = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 9 | ▶ | my $imports = (@args ? 'qw(' . join(' ',@args) . ')' : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 9 | $desc = "use $module $vers $imports"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 9 | my @inc = map { "unshift(\@INC,'$_');\n" } ($$self{'libdir'},$$self{'testdir'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # So the following do not get picked up by cpantorpm-depreq or other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # tools that try to determine dependencies and prereqs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 9 | my $p = "package"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 9 | $code = <<USE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | $p $pack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | @inc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | use $module $vers $imports; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | USE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $self->_not_ok('use module: no module specified'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 12 | ▶ | $desc .= ' (should not load)' if ($mode eq 'forbid'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 12 | ▶ | $desc .= ' (feature)' if ($mode eq 'feature'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 12 | my($eval_result,$eval_error) = $self->_eval($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 12 | chomp($eval_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 12 | my @eval_error = split(/\n/,$eval_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 12 | @eval_error = grep(!/^BEGIN failed--compilation aborted/,@eval_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 12 | foreach my $err (@eval_error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 6 | $err =~ s/ \(\@INC contains.*//; # strip out the actual @INC values | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 12 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 12 | ▶ | if ($eval_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # Able to load the module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 6 | ▶ | if ($mode eq 'forbid') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $$self{'skipall'} = 'Loaded a module not supposed to be present'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $self->_not_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | $self->_diag('Test required that module not be usable') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless ($$self{'quiet'} == 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } elsif ($mode eq 'feature') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | $self->feature($module,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 1 | ▶ | if (! $$self{'quiet'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 1 | $self->_diag($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | $self->_diag("Feature available: $module"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 5 | $self->_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Unable to load the module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 6 | ▶ | if ($mode eq 'forbid') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 5 | $self->_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } elsif ($mode eq 'feature') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | $self->feature($module,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | if (! $$self{'quiet'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | $self->_diag($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | $self->_diag("Feature unavailable: $module"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $$self{'skipall'} = 'Unable to load a required module'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $self->_not_ok($desc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | if ( ($ok && $$self{'quiet'}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 12 | ▶ | (! $ok && $$self{'quiet'} == 2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok and $self->{"quiet"}
not $ok and $self->{"quiet"} == 2
MC/DC0%0/4
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok
$self->{"quiet"}
not $ok
$self->{"quiet"} == 2
Truth table14%1/7
A and B or not(C) and D
A= $okB= $self->{"quiet"}C= not $okD= $self->{"quiet"} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 12 | foreach my $err (@eval_error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 6 | $self->_diag($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 13 | ▶ | sub _is_module_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_module_name: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 13 | my($self,$module) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # Module names start with a letter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # End with an alphanumeric. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # The rest is an alphanumeric or :: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 13 | $module =~ s/\b::\b//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 13 | ▶ | return $module =~ /^[a-zA-Z]\w*$/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 18 | ▶ | sub _eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eval: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 18 | my($self,$code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 18 | my( $sigdie, $eval_result, $eval_error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 18 | local( $@, $!, $SIG{__DIE__} ); # isolate eval | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | $eval_result = eval $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 18 | $eval_error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 18 | ▶ | $sigdie = $SIG{__DIE__} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$SIG{'__DIE__'} || undef
MC/DC0%0/1
$SIG{'__DIE__'} || undef
$SIG{'__DIE__'}
Truth table50%1/2
A
A= $SIG{'__DIE__'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # make sure that $code got a chance to set $SIG{__DIE__} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 18 | ▶ | $SIG{__DIE__} = $sigdie if defined $sigdie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 18 | return( $eval_result, $eval_error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # OK/IS/ISNT METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 17 | ▶ | sub ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ok: called CC=8 SCAR=26.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 17 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 17 | $main::TI_NUM++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 17 | my($op,@ret) = $self->_ok_result(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 17 | my($name,@diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 17 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 17 | ▶ | if ($op eq 'skip') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $reason = shift(@ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->_skip($reason); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } elsif ($op eq 'pass') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 17 | ($name,@diag) = @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 17 | $self->_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ($name,@diag) = @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $self->_not_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | if ( ($ok && $$self{'quiet'}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 17 | ▶ | (! $ok && $$self{'quiet'} == 2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok and $self->{"quiet"}
not $ok and $self->{"quiet"} == 2
MC/DC0%0/4
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok
$self->{"quiet"}
not $ok
$self->{"quiet"} == 2
Truth table14%1/7
A and B or not(C) and D
A= $okB= $self->{"quiet"}C= not $okD= $self->{"quiet"} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 17 | foreach my $diag (@diag) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 18 | $self->_diag($diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 20 | ▶ | sub _ok_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ok_result: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 20 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # Test if we're skipping this test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 20 | my($skip,$reason) = $self->_skip_test(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 20 | ▶ | return ('skip',$reason) if ($skip); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # No args == always pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 20 | ▶ | if (@args == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | return ('pass','Empty test'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # Get the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 19 | my($func,$funcargs,$result) = $self->_get_result(\@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # Get name/expected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 19 | my($name,$expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 19 | ▶ | if (@args == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 6 | $name = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } elsif (@args == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 10 | ($expected,$name) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } elsif (@args > 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | return(0,'','Improperly formed test: too many arguments'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | # Check the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 19 | my($pass,@diag) = $self->_cmp_result('ok',$func,$funcargs,$result,$expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 19 | return($pass,$name,@diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 34 | ▶ | sub is { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 34 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 34 | $self->_is("is",@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 2 | ▶ | sub isnt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isnt: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | my($self,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | $self->_is("isnt",@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 43 | ▶ | sub _is { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is: called CC=8 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 43 | my($self,$is,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 43 | $main::TI_NUM++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 43 | my($op,@ret) = $self->_is_result($is,@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 43 | my($name,@diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 43 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 43 | ▶ | if ($op eq 'skip') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 21 | my $reason = shift(@ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 21 | $self->_skip($reason); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } elsif ($op eq 'pass') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 22 | ($name,@diag) = @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 22 | $self->_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ($name,@diag) = @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $self->_not_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | if ( ($ok && $$self{'quiet'}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 43 | ▶ | (! $ok && $$self{'quiet'} == 2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok and $self->{"quiet"}
not $ok and $self->{"quiet"} == 2
MC/DC0%0/4
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok
$self->{"quiet"}
not $ok
$self->{"quiet"} == 2
Truth table14%1/7
A and B or not(C) and D
A= $okB= $self->{"quiet"}C= not $okD= $self->{"quiet"} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 43 | foreach my $diag (@diag) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | $self->_diag($diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 56 | ▶ | sub _is_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_result: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 56 | my($self,$is,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # Test if we're skipping this test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 56 | my($skip,$reason) = $self->_skip_test(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 56 | ▶ | return ('skip',$reason) if ($skip); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | # Test args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 35 | ▶ | if (@args < 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | return ('fail','','Improperly formed test: too few arguments'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 35 | my($func,$funcargs,$result) = $self->_get_result(\@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 35 | my($name,$expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 35 | ▶ | if (@args == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ($expected) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } elsif (@args == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 35 | ($expected,$name) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | return(0,'','Improperly formed test: too many arguments'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # Check the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 35 | my($pass,@diag) = $self->_cmp_result($is,$func,$funcargs,$result,$expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 35 | return($pass,$name,@diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # Returns $func,$args and $results. The first two are returned only if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # there is a function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 54 | ▶ | sub _get_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_result: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 54 | my($self,$args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 54 | my($func,@funcargs,@result,$result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 54 | ▶ | if (ref($$args[0]) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 21 | $func = shift(@$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 21 | ▶ | if (ref($$args[0]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 17 | @funcargs = @{ $$args[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 17 | shift(@$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 21 | @result = &$func(@funcargs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 21 | return ($func,\@funcargs,\@result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } elsif (ref($$args[0]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 7 | @result = @{ $$args[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 7 | shift(@$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 7 | return ('','',\@result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 26 | $result = shift(@$args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 26 | return ('','',$result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 54 | ▶ | sub _cmp_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmp_result: called CC=17 SCAR=28.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 54 | my($self,$type,$func,$funcargs,$result,$expected) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 54 | my $pass = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 54 | my $identical = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 54 | my @diag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 54 | ▶ | if ($type eq 'ok') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 19 | ▶ | if (ref($result) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 13 | foreach my $ele (@$result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 18 | ▶ | $pass = 1 if (defined($ele)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } elsif (ref($result) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 2 | foreach my $key (keys %$result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 4 | my $val = $$result{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 4 | ▶ | $pass = 1 if (defined($val)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 4 | ▶ | $pass = ($result ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 19 | ▶ | if (! defined($expected)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # If no expected result passed in, we don't test the results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 9 | $identical = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # Results/expected must be the same structure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 10 | $identical = $self->_cmp_structure($result,$expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 35 | $identical = $self->_cmp_structure($result,$expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 35 | ▶ | if ($type eq 'is') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 33 | $pass = $identical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 2 | $pass = 1 - $identical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 54 | ▶ | if (! $identical && $type ne 'isnt') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $identical and $type ne "isnt"
MC/DC100%2/2
not $identical and $type ne "isnt"
not $identical
$type ne "isnt"
Truth table100%3/3
not(A) and B
A= not $identicalB= $type ne "isnt"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 7 | ▶ | if ($func) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 4 | push(@diag,"Arguments: " . $self->_stringify($funcargs)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 7 | push(@diag, "Results : " . $self->_stringify($result)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 7 | ▶ | push(@diag, "Expected : " . $self->_stringify($expected)) unless ($type eq 'ok' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "ok" and not defined $result
MC/DC0%0/2
$type eq "ok" and not defined $result
$type eq "ok"
not defined $result
Truth table33%1/3
A and not(B)
A= $type eq "ok"B= not defined $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ! defined($result)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 54 | ▶ | return (($pass ? 'pass' : 'fail'),@diag); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # Turn a data structure into a string (poor-man's Data::Dumper) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 18 | ▶ | sub _stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stringify: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 18 | my($self,$s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 18 | my($str) = $self->__stringify($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 18 | my($width) = $$self{'width'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 18 | ▶ | if ($width) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 18 | $width -= 21; # The leading string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 18 | ▶ | $width = 10 if ($width < 10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 18 | ▶ | $str = substr($str,0,$width) if (length($str)>$width); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 18 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 38 | ▶ | sub __stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__stringify: called CC=11 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 38 | my($self,$s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 38 | ▶ | if (! defined($s)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | return '__undef__'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } elsif (ref($s) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 10 | my $str = '[ '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 10 | foreach my $val (@$s) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 12 | $str .= $self->__stringify($val) . ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 10 | $str .= ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 10 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } elsif (ref($s) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 2 | my $str = '{ '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 2 | foreach my $key (sort keys %$s) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 4 | my $key = $self->__stringify($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 4 | my $val = $self->__stringify($$s{$key}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 4 | $str .= "$key=>$val "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 2 | $str .= '}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } elsif (ref($s)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | return '<' . ref($s) . '>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | } elsif ($s eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | return "''"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 26 | ▶ | if ($s =~ /\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my $q = qr/\'/; # single quote | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $qq = qr/\"/; # double quote | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | if ($s !~ $q) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | return "'$s'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | if ($s !~ $qq) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | return '"' . $s . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | return "<$s>"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 26 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 87 | ▶ | sub _cmp_structure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmp_structure: called CC=16 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 87 | my($self,$s1,$s2) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 87 | ▶ | return 1 if (! defined($s1) && ! defined($s2)); # undef = undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $s1 or defined $s2
MC/DC0%0/2
defined $s1 or defined $s2
defined $s1
defined $s2
Truth table33%1/3
A or B
A= defined $s1B= defined $s2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 87 | ▶ | return 0 if (! defined($s1) || ! defined($s2)); # undef != def | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $s1 and defined $s2
MC/DC0%0/2
defined $s1 and defined $s2
defined $s1
defined $s2
Truth table33%1/3
A and B
A= defined $s1B= defined $s2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 87 | ▶ | return 0 if (ref($s1) ne ref($s2)); # must be same type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 83 | ▶ | if (ref($s1) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 17 | ▶ | return 0 if ($#$s1 != $#$s2); # two lists must be the same length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 17 | ▶ | foreach (my $i=0; $i<=$#$s1; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 35 | ▶ | return 0 unless $self->_cmp_structure($$s1[$i],$$s2[$i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 15 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } elsif (ref($s1) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 4 | my @k1 = keys %$s1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 4 | my @k2 = keys %$s2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 4 | ▶ | return 0 if ($#k1 != $#k2); # two hashes must be the same length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 4 | foreach my $key (@k1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 7 | ▶ | return 0 if (! exists $$s2{$key}); # keys must be the same | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 7 | ▶ | return 0 unless $self->_cmp_structure($$s1{$key},$$s2{$key}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } elsif (ref($s1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | # Two references (other than ARRAY and HASH are assumed equal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # Two scalars are compared stringwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 62 | return ($s1 eq $s2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 76 | ▶ | sub _skip_test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_skip_test: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 76 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 76 | ▶ | if ($$self{'skipall'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | return (1,$$self{'skipall'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | ▶ | } elsif ( $main::TI_NUM < $$self{'start'} || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$main::TI_NUM < $self->{"start"} or $self->{"end"} and $main::TI_NUM > $self->{"end"}
$self->{"end"} and $main::TI_NUM > $self->{"end"}
MC/DC100%3/3
$main::TI_NUM < $self->{"start"} or $self->{"end"} and $main::TI_NUM > $self->{"end"}
$main::TI_NUM < $self->{"start"}
$self->{"end"}
$main::TI_NUM > $self->{"end"}
Truth table100%4/4
A or B and C
A= $main::TI_NUM < $self->{"start"}B= $self->{"end"}C= $main::TI_NUM > $self->{"end"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | ($$self{'end'} && $main::TI_NUM > $$self{'end'}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 21 | return (1,'Test not in list of tests specified to run'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 55 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | # FILE METHOD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 2 | ▶ | sub file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file: called CC=21 SCAR=36.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 2 | my($self,$func,$input,$outputdir,$expected,$name,@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 2 | ▶ | $name = "" if (! $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 2 | ▶ | if (! (ref($func) eq 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | $self->_die("file method required a coderef"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 2 | my @funcargs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 2 | my $testdir = $$self{'testdir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | # Input file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 2 | ▶ | if ($input) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | ▶ | if (-r $input) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | # Nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } elsif (-r "$testdir/$input") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 1 | $input = "$testdir/$input"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $self->_die("Input file not readable: $input"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 1 | push(@funcargs,$input); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | # Output file and directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 2 | ▶ | if (! $outputdir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 2 | ▶ | if (-d $testdir && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-d $testdir and -w $testdir
MC/DC0%0/2
-d $testdir and -w $testdir
-d $testdir
-w $testdir
Truth table33%1/3
A and B
A= -d $testdirB= -w $testdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | -w $testdir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 | $outputdir = $testdir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | $outputdir = "."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 2 | ▶ | if ($outputdir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 2 | ▶ | if (! -d $outputdir || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-d $outputdir and -w $outputdir
MC/DC0%0/2
-d $outputdir and -w $outputdir
-d $outputdir
-w $outputdir
Truth table33%1/3
A and B
A= -d $outputdirB= -w $outputdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | ! -w $outputdir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | $self->_die("Output directory not writable: $outputdir"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 2 | my $output = "$outputdir/tmp_test_inter"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 2 | push(@funcargs,$output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | # Expected output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 2 | ▶ | if (! $expected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $self->_die("Expected output file not specified"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } elsif (-r $expected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | # Nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } elsif (-r "$testdir/$expected") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 2 | $expected = "$testdir/$expected"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | $self->_die("Expected output file not readable: $expected"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | # Create the temporary output file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 2 | &$func(@funcargs,@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 2 | ▶ | if (! -r "$output") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | $self->_die("Output file not created"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | # Test each line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 2 | my $in = new IO::File; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 2 | $in->open($output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 2 | my @out = <$in>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 2 | $in->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 2 | chomp(@out); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 2 | $in->open($expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 2 | my @exp = <$in>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 2 | $in->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 2 | chomp(@exp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 2 | ▶ | unlink($output) if (! $ENV{'TI_NOCLEAN'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 2 | ▶ | while (@out < @exp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | push(@out,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 2 | ▶ | while (@exp < @out) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | push(@exp,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 2 | ▶ | for (my $i=0; $i<@out; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 7 | my $line = $i+1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 7 | ▶ | my $n = ($name ? "$name : Line $line" : "Line $line"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 7 | $self->_is('is',$out[$i],$exp[$i],$n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | # TESTS METHOD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 4 | ▶ | sub tests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tests: called CC=44 SCAR=53.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 4 | my($self,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | # feature => [ FEATURE, FEATURE, ... ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | # disable => [ FEATURE, FEATURE, ... ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 4 | my $skip = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 4 | ▶ | if (exists $opts{'feature'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | foreach my $feature (@{ $opts{'feature'} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | $skip = "Required feature unavailable: $feature", last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | if (! exists $$self{'features'}{$feature} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | ! $$self{'features'}{$feature}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"features"}{$feature} and $self->{"features"}{$feature}
MC/DC0%0/2
exists $self->{"features"}{$feature} and $self->{"features"}{$feature}
exists $self->{"features"}{$feature}
$self->{"features"}{$feature}
Truth table0%0/3
A and B
A= exists $self->{"features"}{$feature}B= $self->{"features"}{$feature}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 4 | ▶ | if (exists $opts{'disable'} && ! $skip) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $opts{"disable"} and not $skip
MC/DC0%0/2
exists $opts{"disable"} and not $skip
exists $opts{"disable"}
not $skip
Truth table33%1/3
A and not(B)
A= exists $opts{"disable"}B= not $skip
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | foreach my $feature (@{ $opts{'disable'} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | $skip = "Disabled due to feature being available: $feature", last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | if (exists $$self{'features'}{$feature} && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | $$self{'features'}{$feature}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"features"}{$feature} and $self->{"features"}{$feature}
MC/DC0%0/2
exists $self->{"features"}{$feature} and $self->{"features"}{$feature}
exists $self->{"features"}{$feature}
$self->{"features"}{$feature}
Truth table0%0/3
A and B
A= exists $self->{"features"}{$feature}B= $self->{"features"}{$feature}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | # name => NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | # skip => REASON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # todo => 0/1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 4 | my $name = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 4 | ▶ | if (exists $opts{'name'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | $name = $opts{'name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 4 | ▶ | if (exists $opts{'skip'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $skip = $opts{'skip'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 4 | my $todo = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 4 | ▶ | if (exists $opts{'todo'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | $todo = $opts{'todo'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # tests => STRING OR LISTREF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | # func => CODEREF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # expected => STRING OR LISTREF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | # tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 4 | ▶ | if (! exists $opts{'tests'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | $self->_die("invalid test format: tests required"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 4 | my $tests = $opts{'tests'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 4 | my(%tests,$gotexpected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 4 | my($ntest,$nexp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 4 | ▶ | if (ref($tests) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | my @results = @$tests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $ntest = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | foreach my $result (@results) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | $ntest++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | $tests{$ntest}{'err'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | ▶ | if (ref($result) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | $tests{$ntest}{'args'} = $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | $tests{$ntest}{'args'} = [$result]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | $gotexpected = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 4 | ($ntest,$gotexpected,%tests) = $self->_parse($tests); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 4 | ▶ | $nexp = $ntest if ($gotexpected); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # expected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 4 | ▶ | if (exists $opts{'expected'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 2 | ▶ | if ($gotexpected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | $self->_die("invalid test format: expected results included twice"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 2 | my $expected = $opts{'expected'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 2 | ▶ | if (ref($expected) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 1 | my @exp = @$expected; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 1 | $nexp = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 1 | foreach my $exp (@exp) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 1 | $nexp++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 1 | ▶ | if (ref($exp) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 1 | $tests{$nexp}{'expected'} = $exp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | $tests{$nexp}{'expected'} = [$exp]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 1 | my($g,%t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 1 | ($nexp,$g,%t) = $self->_parse($expected); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 1 | ▶ | if ($g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | $self->_die("invalid test format: expected results contain '=>'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 1 | foreach my $t (1..$nexp) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 1 | $tests{$t}{'expected'} = $t{$t}{'args'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 2 | $gotexpected = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 4 | ▶ | if ($gotexpected && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$gotexpected and ($nexp != 1 and $nexp != $ntest)
$nexp != 1 and $nexp != $ntest
MC/DC0%0/3
$gotexpected and ($nexp != 1 and $nexp != $ntest)
$gotexpected
$nexp != 1
$nexp != $ntest
Truth table75%3/4
A and B and C
A= $gotexpectedB= $nexp != 1C= $nexp != $ntest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | ($nexp != 1 && $nexp != $ntest)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | $self->_die("invalid test format: number expected results differs from number of tests"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | # func | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 4 | my $func; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 4 | ▶ | if (exists $opts{'func'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 3 | $func = $opts{'func'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 3 | ▶ | if (ref($func) ne 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | $self->_die("invalid test format: func must be a code reference"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | # Compare results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 4 | foreach my $t (1..$ntest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 16 | $main::TI_NUM++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 16 | ▶ | if ($skip) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | $self->_skip($skip,$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 16 | ▶ | if ($tests{$t}{'err'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | $self->_not_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | $self->diag($tests{$t}{'err'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 16 | my($op,@ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # Test results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 16 | ▶ | if ($gotexpected) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | # Do an 'is' test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 13 | my @a = ('is'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 13 | ▶ | push(@a,$func) if ($func); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 13 | push(@a,$tests{$t}{'args'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | push(@a,($nexp == 1 ? $tests{'1'}{'expected'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 13 | ▶ | : $tests{$t}{'expected'})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 13 | push(@a,$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 13 | ($op,@ret) = $self->_is_result(@a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | # Do an 'ok' test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 3 | my $result = $tests{$t}{'args'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 3 | ▶ | if (@$result == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | $result = $$result[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 3 | ($op,@ret) = $self->_ok_result($result,$name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | # Print it out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 16 | my($name,@diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 16 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 16 | ▶ | if ($op eq 'skip') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | my $reason = shift(@ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | $self->_skip($reason); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } elsif ($op eq 'pass') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 16 | ($name,@diag) = @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 16 | $self->_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | ($name,@diag) = @ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | $self->_not_ok($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | $ok = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | if ( ($ok && $$self{'quiet'}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 16 | ▶ | (! $ok && $$self{'quiet'} == 2) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok and $self->{"quiet"}
not $ok and $self->{"quiet"} == 2
MC/DC0%0/4
$ok and $self->{"quiet"} or not $ok and $self->{"quiet"} == 2
$ok
$self->{"quiet"}
not $ok
$self->{"quiet"} == 2
Truth table14%1/7
A and B or not(C) and D
A= $okB= $self->{"quiet"}C= not $okD= $self->{"quiet"} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 16 | foreach my $diag (@diag) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | $self->_diag($diag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # TAP METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 35 | ▶ | sub _diag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_diag: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 35 | my($self,$message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 35 | print '#' . ' 'x10 . "$message\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 16 | ▶ | sub _plan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_plan: called CC=7 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 16 | my($self,$n,$reason) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 16 | ▶ | $reason = '' if (! $reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 16 | ▶ | if ($$self{'mode'} eq 'test') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | # Test mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 16 | ▶ | if (! $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 2 | ▶ | $reason = '' if (! $reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 2 | print "1..0 # Skipped $reason\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 14 | print "1..$n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | ▶ | if (! $n) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | print " All tests skipped: $reason\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | print " Epected number of tests: $n\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | unless ($$self{'quiet'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 69 | ▶ | sub _ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ok: called CC=6 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 69 | my($self,$name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 69 | ▶ | $name = '' if (! $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 69 | $name =~ s/\#//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 69 | $$self{'testsrun'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | return if ($$self{'mode'} ne 'test' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 69 | ▶ | $$self{'quiet'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"mode"} ne "test" and $self->{"quiet"}
MC/DC0%0/2
$self->{"mode"} ne "test" and $self->{"quiet"}
$self->{"mode"} ne "test"
$self->{"quiet"}
Truth table33%1/3
A and B
A= $self->{"mode"} ne "test"B= $self->{"quiet"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 69 | print "ok $main::TI_NUM" . ' 'x(8-length($main::TI_NUM)) . "$name\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 69 | ▶ | if ($name =~ /^\d/ && $$self{'quiet'} != 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$name =~ /^\d/ and $self->{"quiet"} != 2
MC/DC0%0/2
$name =~ /^\d/ and $self->{"quiet"} != 2
$name =~ /^\d/
$self->{"quiet"} != 2
Truth table33%1/3
A and B
A= $name =~ /^\d/B= $self->{"quiet"} != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | $self->_diag('It is strongly recommended that the name of a test not'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | $self->_diag('begin with a digit so it will not be confused with the'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | $self->_diag('test number.'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | sub _not_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_not_ok: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | my($self,$name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | ▶ | $name = '' if (! $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | $name =~ s/\#//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $$self{'testsrun'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | print "not ok $main::TI_NUM" . ' 'x(4-length($main::TI_NUM)) . "$name\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | ▶ | if ($$self{'abort'} == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | } elsif ($$self{'abort'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | $$self{'skipall'} = 'Tests aborted due to failed test'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 21 | ▶ | sub _skip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_skip: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 21 | my($self,$reason,$name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 21 | ▶ | $name = '' if (! $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 21 | $name =~ s/\#//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 21 | $$self{'testsrun'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | return if ($$self{'mode'} ne 'test' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 21 | ▶ | $$self{'quiet'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"mode"} ne "test" and $self->{"quiet"}
MC/DC0%0/2
$self->{"mode"} ne "test" and $self->{"quiet"}
$self->{"mode"} ne "test"
$self->{"quiet"}
Truth table33%1/3
A and B
A= $self->{"mode"} ne "test"B= $self->{"quiet"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 21 | ▶ | print "ok $main::TI_NUM" . ' 'x(8-length($main::TI_NUM)) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | ($name ? "$name " : "") . "# SKIPPED $reason\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | # TEST PARSING METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 16 | my $l; # current line number | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 16 | my $sp_opt = qr/\s*/; # optional whitespace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 16 | my $sp = qr/\s+/; # required whitespace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 16 | my $lparen = qr/\(/; # opening paren | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 16 | my $lbrack = qr/\[/; # opening brack | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 16 | my $lbrace = qr/\{/; # opening brace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 16 | my $q = qr/\'/; # single quote | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 16 | my $qq = qr/\"/; # double quote | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 16 | my $token = qr/\S+/; # a token of non-whitespace characters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 16 | my $min_str = qr/.*?/; # a minimum length string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 16 | my $results = qr/=>/; # the string to switch to results | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | # We'll also need to match delimiters and other special characters that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | # signal the end of a token. The default delimiter is just whitespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | # both other end-of-token regular expressions will include closing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | # parens, delimiters, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | # The end-of-token regexp will return a match for a special character (if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # any) that terminates the token. If a token ends a whitespace or EOL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | # nothing is matched. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 16 | my $eot = qr/()(?:\s+|$)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | # Allowed delimiters is anything except () [] {} alphanumeric, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | # underscore, and whitespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 16 | my $delim = qr/[^\'\"\(\)\[\]\{\}a-zA-Z0-9_ \t]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | # This takes a string which may contain a partial or complete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | # descritpion of any number of tests, and parses it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | # The string is multiline, and tests must be separated from each other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | # by one or more blank lines. Lines starting with a pound sign (#) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | # are comments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | # A test may include arguments (or obtained results), expected results, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | # or both. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | # Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | # ($n,$gotboth,%tests) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # $n is the number of tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | # $gotboth is 1 if both arguments and expected results are obtained | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | # $tests{$i} is the i'th test. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 5 | ▶ | sub _parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 5 | my($self,$string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 5 | my $t = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 5 | my $gotboth = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 5 | my %tests = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # Split on newlines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 5 | $string = [ split(/\n/s,$string) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 5 | $t = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 5 | ▶ | while (@$string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 17 | my $test = $self->_next_test($string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 17 | ▶ | last if (! @$test); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | # All tests must contain both args/results OR only one of them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 17 | my ($err,$both,$args,$results) = $self->_parse_test($test); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 17 | ▶ | if ($gotboth == -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 5 | $gotboth = $both; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } elsif ($gotboth != $both) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | $err = "Malformed test [$l]: expected results for some tests, not others"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 17 | $t++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 17 | $tests{$t}{'err'} = $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 17 | $tests{$t}{'args'} = $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 17 | ▶ | $tests{$t}{'expected'} = $results if ($gotboth); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 5 | return ($t,$gotboth,%tests); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | # Get all lines up to the end of lines or a blank line. Both | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | # signal the end of a test. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 17 | ▶ | sub _next_test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_next_test: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 17 | my($self,$list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 17 | my @test; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 17 | my $started = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 17 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 34 | ▶ | last if (! @$list); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 33 | my $line = shift(@$list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 33 | $line =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 33 | $line =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | # If it's a blank line, add it to the test. If we've | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | # already done test lines, then this signals the end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | # of the test. Otherwise, this is before the test, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | # so keep looking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 33 | ▶ | if ($line eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 16 | push(@test,$line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 16 | ▶ | next if (! $started); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 16 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # Comments are added to the test as a blank line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 17 | ▶ | if ($line =~ /^#/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | push(@test,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 17 | push(@test,$line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 17 | $started = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 17 | ▶ | return [] if (! $started); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 17 | return \@test; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | # Parse an entire test. Look for arguments, =>, and expected results. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 17 | ▶ | sub _parse_test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_test: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 17 | my($self,$test) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 17 | my($err,$both,@args,@results); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 17 | my $curr = 'args'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 17 | ▶ | while (@$test) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 68 | ▶ | last if (! $self->_test_line($test)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | # Check for '=>' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 51 | ▶ | if ($self->_parse_begin_results($test)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 7 | ▶ | if ($curr eq 'args') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 7 | $curr = 'results'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | return ("Malformed test [$l]: '=>' found twice"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 7 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | # Get the next item(s) to add. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 44 | my($err,$match,@val) = $self->_parse_token($test,$eot); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 44 | ▶ | return ($err) if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 44 | ▶ | if ($curr eq 'args') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 29 | push(@args,@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 15 | push(@results,@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 17 | ▶ | $both = ($curr eq 'results' ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 17 | return ("",$both,\@args,\@results); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | # Makes sure that the first line in the test contains | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | # something. Blank lines are ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 129 | ▶ | sub _test_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_test_line: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 129 | my($self,$test) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 129 | ▶ | while (@$test && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$test and !defined($test->[0]) || $test->[0] eq ""
not defined $test->[0] or $test->[0] eq ""
MC/DC66%2/3
@$test and !defined($test->[0]) || $test->[0] eq ""
@$test
not defined $test->[0]
$test->[0] eq ""
Truth table75%3/4
A and not(B) or C
A= @$testB= not defined $test->[0]C= $test->[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | (! defined($$test[0]) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | $$test[0] eq '')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 33 | shift(@$test); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 33 | $l++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 33 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 129 | ▶ | return 1 if (@$test); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 17 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | # Check for '=>'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | # Return 1 if found, 0 otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 51 | ▶ | sub _parse_begin_results { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_begin_results: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 51 | my($self,$test) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 51 | ▶ | return 1 if ($$test[0] =~ s/^ $sp_opt $results $eot //x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 44 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | # Gets the next item to add to the current list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | # Returns ($err,$match,@val) where $match is the character that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | # matched the end of the current element (either a delimiter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | # closing character, or nothing if the element ends on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | # whitespace/newline). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 61 | ▶ | sub _parse_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_token: called CC=27 SCAR=40.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 61 | my($self,$test,$EOT) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 61 | my($err,$found,$match,@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 61 | ▶ | last if (! $self->_test_line($test)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | # Check for quoted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 61 | ($err,$found,$match,@val) = $self->_parse_quoted($test,$EOT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 61 | ▶ | last if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 61 | ▶ | if ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | # '' remains '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | # Check for open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 59 | ($err,$found,$match,@val) = $self->_parse_open_close($test,$EOT,$lparen,')'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 59 | ▶ | last if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 59 | ▶ | if ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | # () is an empty list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 7 | ▶ | if (@val == 1 && $val[0] eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@val == 1 and $val[0] eq ""
MC/DC0%0/2
@val == 1 and $val[0] eq ""
@val == 1
$val[0] eq ""
Truth table66%2/3
A and B
A= @val == 1B= $val[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 0 | @val = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 7 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 52 | ($err,$found,$match,@val) = $self->_parse_open_close($test,$EOT,$lbrack,']'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 52 | ▶ | last if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 52 | ▶ | if ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | # [] is [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 2 | ▶ | if (@val == 1 && $val[0] eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@val == 1 and $val[0] eq ""
MC/DC0%0/2
@val == 1 and $val[0] eq ""
@val == 1
$val[0] eq ""
Truth table33%1/3
A and B
A= @val == 1B= $val[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 2 | @val = ([]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 0 | @val = ( [@val] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 50 | ($err,$found,$match,@val) = $self->_parse_open_close($test,$EOT,$lbrace,'}'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 50 | ▶ | last if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 50 | ▶ | if ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 2 | ▶ | if (@val == 1 && $val[0] eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
@val == 1 and $val[0] eq ""
MC/DC0%0/2
@val == 1 and $val[0] eq ""
@val == 1
$val[0] eq ""
Truth table33%1/3
A and B
A= @val == 1B= $val[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 2 | @val = ( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | } elsif (@val % 2 == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # Even number of elements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | @val = ( {@val} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | ▶ | } elsif (! defined $val[$#val] || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not defined $val[$#val] or $val[$#val] eq ""
MC/DC0%0/2
not defined $val[$#val] or $val[$#val] eq ""
not defined $val[$#val]
$val[$#val] eq ""
Truth table0%0/3
not(A) or B
A= not defined $val[$#val]B= $val[$#val] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | $val[$#val] eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # Odd number of elements with nothing as the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | # last element. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | pop(@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | @val = ( {@val} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | # Odd number of elements not supported for a hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | $err = "Malformed test [$l]: hash with odd number of elements"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | # Check for some other token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 48 | ($err,$found,$match,@val) = $self->_parse_simple_token($test,$EOT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 48 | ▶ | last if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 48 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 61 | ▶ | return ($err) if ($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 61 | ▶ | return ("Malformed test: unable to parse") if (! $found); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 61 | foreach my $v (@val) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 68 | ▶ | $v = '' if ($v eq '__blank__'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 68 | ▶ | $v = undef if ($v eq '__undef__'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 68 | ▶ | $v =~ s/__nl__/\n/g if ($v); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 61 | ▶ | return (0,$match,@val) if ($found); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | return (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | ### The next few routines parse parts of the test. Each of them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | ### take as arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | ### $test : the listref containing the unparsed portion of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | ### the test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | ### $EOT : the end of a token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | ### + other args as needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | ### They all return: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | ### $err : a string containing the error (if any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | ### $found : 1 if something matched | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | ### $match : the character which terminates the current | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | ### token signaling the start of the next token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | ### (this will either be a delimiter, a closing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | ### character, or nothing if the string ended on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | ### whitespace or a newline) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | ### @val : the value (or values) of the token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | # Check for a quoted string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | # 'STRING' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | # "STRING" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | # The string must be on one line, and everything up to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | # closing quote is included (the quotes themselves are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | # stripped). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 61 | ▶ | sub _parse_quoted { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_quoted: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 61 | my($self,$test,$EOT) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 61 | ▶ | if ($$test[0] =~ s/^ $sp_opt $q ($min_str) $q $EOT//x || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$test->[0] =~ s/^ $sp_opt $q ($min_str) $q $EOT//x or $test->[0] =~ s/^ $sp_opt $qq ($min_str) $qq $EOT//x
MC/DC50%1/2
$test->[0] =~ s/^ $sp_opt $q ($min_str) $q $EOT//x or $test->[0] =~ s/^ $sp_opt $qq ($min_str) $qq $EOT//x
$test->[0] =~ s/^ $sp_opt $q ($min_str) $q $EOT//x
$test->[0] =~ s/^ $sp_opt $qq ($min_str) $qq $EOT//x
Truth table66%2/3
A or B
A= $test->[0] =~ s/^ $sp_opt $q ($min_str) $q $EOT//xB= $test->[0] =~ s/^ $sp_opt $qq ($min_str) $qq $EOT//x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | $$test[0] =~ s/^ $sp_opt $qq ($min_str) $qq $EOT//x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 2 | return (0,1,$2,$1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | ▶ | } elsif ($$test[0] =~ /^ $sp_opt $q/x || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$test->[0] =~ /^ $sp_opt $q/x or $test->[0] =~ /^ $sp_opt $qq/x
MC/DC0%0/2
$test->[0] =~ /^ $sp_opt $q/x or $test->[0] =~ /^ $sp_opt $qq/x
$test->[0] =~ /^ $sp_opt $q/x
$test->[0] =~ /^ $sp_opt $qq/x
Truth table33%1/3
A or B
A= $test->[0] =~ /^ $sp_opt $q/xB= $test->[0] =~ /^ $sp_opt $qq/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | $$test[0] =~ /^ $sp_opt $qq/x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | return ("Malformed test [$l]: improper quoting"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 59 | return (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | # Parses an open/close section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # ( TOKEN TOKEN ... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | # (, TOKEN, TOKEN, ... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | # $open is a regular expression matching the open, $close is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | # actual closing character. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | # After the closing character must be an $EOT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 161 | ▶ | sub _parse_open_close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_open_close: called CC=13 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 161 | my($self,$test,$EOT,$open,$close) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | # See if there is an open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 161 | my($del,$newEOT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 161 | ▶ | if ($$test[0] =~ s/^ $sp_opt $open ($delim) $sp_opt //x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 2 | $del = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 2 | $newEOT = qr/ $sp_opt ($|\Q$del\E|\Q$close\E) /x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | } elsif ($$test[0] =~ s/^ $sp_opt $open $sp_opt //x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 9 | $del = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 9 | $newEOT = qr/ ($sp_opt $|$sp_opt \Q$close\E|$sp) /x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 150 | return (0,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | # If there was, then we need to read tokens until either: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | # the string is all used up => error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | # $close is found | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 11 | my($match,@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 11 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | # Get a token. We MUST find something valid even if it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | # an empty list followed by the closing character. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 17 | my($e,$m,@v) = $self->_parse_token($test,$newEOT); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 17 | ▶ | return ($e) if ($e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 17 | $m =~ s/^$sp//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | # If we ended on nothing, and $del is something, then we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | # ended on a newline with no delimiter. The next line MUST | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | # start with a delimiter or close character or the test is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | # invalid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 17 | ▶ | if (! $m && $del) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $m and $del
MC/DC0%0/2
not $m and $del
not $m
$del
Truth table66%2/3
not(A) and B
A= not $mB= $del
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | ▶ | if (! $self->_test_line($test)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | return ("Malformed test [$l]: premature end of test"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | ▶ | if ($$test[0] =~ s/^ $sp_opt $newEOT //x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | $m = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | return ("Malformed test [$l]: unexpected token (expected '$close' or '$del')"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | # Figure out what value(s) were returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 17 | ▶ | if ($m eq $close && ! @v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$m eq $close and not @v
MC/DC0%0/2
$m eq $close and not @v
$m eq $close
not @v
Truth table66%2/3
A and not(B)
A= $m eq $closeB= not @v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | push(@val,''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 17 | push(@val,@v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 17 | ▶ | last if ($m eq $close); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | # Now we need to find out what character ends this token: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 11 | ▶ | if ($$test[0] eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | # Ended at EOL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 2 | return (0,1,'',@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 9 | ▶ | if ($$test[0] =~ s/^ $sp_opt $EOT //x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 9 | return (0,1,$1,@val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | return ("Malformed test [$l]: unexpected token"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | # Checks for a simple token. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 48 | ▶ | sub _parse_simple_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_simple_token: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 48 | my($self,$test,$EOT) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 48 | $$test[0] =~ s/^ $sp_opt (.*?) $EOT//x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 48 | return (0,1,$2,$1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | # Local Variables: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | # mode: cperl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | # cperl-indent-level: 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | # cperl-continued-statement-offset: 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | # cperl-continued-brace-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | # cperl-brace-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | # cperl-brace-imaginary-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | # cperl-label-offset: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | # End: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||