| 1 | package Devel::Assert; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | our $VERSION = '1.06'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | our $__ASSERT_GLOBAL = 0; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | require XSLoader; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | XSLoader::load('Devel::Assert', $VERSION); | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | my ($class, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 13 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | $__ASSERT_GLOBAL = 1 if $arg eq 'global'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | ▶ | my $ref = $arg eq 'off' || !$__ASSERT_GLOBAL && $arg ne 'on' ? \&assert_off : \&assert_on; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$arg eq "off" or not $Devel::Assert::__ASSERT_GLOBAL and $arg ne "on"
not $Devel::Assert::__ASSERT_GLOBAL and $arg ne "on"
MC/DC100%3/3
$arg eq "off" or not $Devel::Assert::__ASSERT_GLOBAL and $arg ne "on"
$arg eq "off"
not $Devel::Assert::__ASSERT_GLOBAL
$arg ne "on"
Truth table100%4/4
A or not(B) and C
A= $arg eq "off"B= not $Devel::Assert::__ASSERT_GLOBALC= $arg ne "on"
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 13 | ▶ | *{"${caller}::assert"} = $ref if !defined *{"${caller}::assert"}{CODE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub assert_off {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert_off: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 12 | ▶ | sub assert_fail { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert_fail: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 12 | my ($op, $cop, $upcv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # idea taken from Zefram's Debug::Show | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # this code knows too much about B::Deparser internals | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 12 | ▶ | unless (state $init_done++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | require B; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | require B::Deparse; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | $Carp::Internal{'Devel::Assert'}++; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 12 | my $deparser = B::Deparse->new; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 12 | $deparser->{curcop} = $cop; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 12 | $deparser->{curcv} = $upcv; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | my $deparsed; | |||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 12 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | ▶ | $deparsed = eval { | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
eval {
do {
$deparser->indent($deparser->deparse($op->sibling, 50))
}
} || '0'
MC/DC100%1/1
eval {
do {
$deparser->indent($deparser->deparse($op->sibling, 50))
}
} || '0'
eval {
do {
$deparser->indent($deparser->deparse($op->sibling, 50))
}
}
Truth table100%2/2
A
A= eval {
do {
$deparser->indent($deparser->deparse($op->sibling, 50))
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | $deparser->indent($deparser->deparse($op->sibling, 50)); | |||||||||||||||||||||||||||||||||||||||||
| 52 | } || "0"; | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 12 | ▶ | warn $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | $deparsed =~ s/\n[\t ]*/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 12 | $deparsed =~ s/^[(]//; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | $deparsed =~ s/[)]$//; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 12 | Carp::confess("Assertion '$deparsed' failed"); | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||