| 1 | package Test::Object::Test; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # Constructor and Accessors | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my $self = bless { @_ }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Check params | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | unless ( _CLASS($self->class) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | Carp::croak("Did not provide a valid test class"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | unless ( _CODELIKE($self->code) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | Carp::croak("Did not provide a valid CODE or callable object"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | sub class { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $_[0]->{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub tests { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tests: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $_[0]->{tests}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub code { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | $_[0]->{code}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Main Methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $_[0]->code->( $_[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ##################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # Support Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Stolen from Params::Util to avoid adding a dependency needlessly | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub _CLASS ($) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_CLASS: called CC=4 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
defined $_[0] and not ref $_[0]
MC/DC0%0/3
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
defined $_[0]
not ref $_[0]
$_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
Truth table25%1/4
A and not(B) and C
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | sub _CODELIKE { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_CODELIKE: called CC=5 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | (Scalar::Util::reftype($_[0])||'') eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition25%2/8
(builtin::reftype($_[0]) || '') eq 'CODE' || builtin::blessed($_[0]) && (overload::Method($_[0], '&{}') ? $_[0] : undef)
builtin::reftype($_[0]) || ''
builtin::blessed($_[0]) and overload::Method($_[0], "&{}") ? $_[0] : undef
MC/DC0%0/3
(builtin::reftype($_[0]) || '') eq 'CODE' || builtin::blessed($_[0]) && (overload::Method($_[0], '&{}') ? $_[0] : undef)
builtin::reftype($_[0])
builtin::blessed($_[0])
overload::Method($_[0], "&{}") ? $_[0] : undef
Truth table25%1/4
A || B and C
A= builtin::reftype($_[0])B= builtin::blessed($_[0])C= overload::Method($_[0], "&{}") ? $_[0] : undef
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | Scalar::Util::blessed($_[0]) and overload::Method($_[0],'&{}') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ? $_[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||