| 1 | ########################################### | ||||||||||||||||||||||||||||
| 2 | package Test::Standalone; | ||||||||||||||||||||||||||||
| 3 | ########################################### | ||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Filter::Util::Call; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Getopt::Std; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | my $CODE = ""; | |||||||||||||||||||||||||||
| 10 | 1 | my $IN_TEST = 0; | |||||||||||||||||||||||||||
| 11 | 1 | my $TEST_START = qr(^=begin test); | |||||||||||||||||||||||||||
| 12 | 1 | my $TEST_END = qr(^=end test); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = "0.01"; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | ########################################### | ||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=13.3
| |||||||||||||||||||||||||||||
| 18 | ########################################### | ||||||||||||||||||||||||||||
| 19 | 1 | my($type, @arguments) = @_ ; | |||||||||||||||||||||||||||
| 20 | 1 | filter_add([]) ; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | if(@ARGV and $ARGV[0] eq "--test") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@ARGV and $ARGV[0] eq "--test"
MC/DC0%0/2
@ARGV and $ARGV[0] eq "--test"
@ARGV
$ARGV[0] eq "--test"
Truth table33%1/3
A and B
A= @ARGVB= $ARGV[0] eq "--test"
| |||||||||||||||||||||||||||||
| 23 | 0 | $IN_TEST = 1; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ########################################### | ||||||||||||||||||||||||||||
| 28 | 8 | ▶ | sub filter { | ||||||||||||||||||||||||||
|
Subroutine
filter: called CC=6 SCAR=19.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | ########################################### | ||||||||||||||||||||||||||||
| 30 | 8 | my $status = filter_read(); | |||||||||||||||||||||||||||
| 31 | 8 | ▶ | if(/$TEST_START/ .. /$TEST_END/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 3 | ▶ | if(!/$TEST_START/ and !/$TEST_END/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
/$TEST_START/ or /$TEST_END/
MC/DC100%2/2
/$TEST_START/ or /$TEST_END/
/$TEST_START/
/$TEST_END/
Truth table100%3/3
A or B
A= /$TEST_START/B= /$TEST_END/
| |||||||||||||||||||||||||||||
| 33 | 1 | $CODE .= $_; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 8 | ▶ | if($IN_TEST) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if( s/^\s*main\s*\(\)/Test::Standalone::test_run()/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | $IN_TEST = 0; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 8 | $status; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | ########################################### | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub test_run { | ||||||||||||||||||||||||||
|
Subroutine
test_run: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | ########################################### | ||||||||||||||||||||||||||||
| 47 | 0 | my $code = "package main; " . | |||||||||||||||||||||||||||
| 48 | Test::Standalone::test_code(); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | eval $code or die "eval failed: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | exit 0; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | ########################################### | ||||||||||||||||||||||||||||
| 55 | 1 | ▶ | sub test_code { | ||||||||||||||||||||||||||
|
Subroutine
test_code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | ########################################### | ||||||||||||||||||||||||||||
| 57 | 1 | return $CODE; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | 1; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||