lib/Tie/Wx/Widget.pm

filter: Statementstmt 38.1% 16 / 42 Branchbran 3.5% 1 / 28 Conditioncond 11.1% 1 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 38.4% 5 / 13 Podpod 0.0% 0 / 3 totaltotal 22.7% 23 / 101 CC 18 SCAR 41.8
CC
18
Cov
23%
TIESCALAR
156.0
STORE
12.0
complain
6.0
CRAP 65.1
↑ Summary
1 1 ▶use v5.6;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Tie::Scalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Tie::Wx::Widget;
7 1 our $VERSION = '1.01';
8 1 our @ISA = 'Tie::Scalar';
9 1 our $complainmethod = 'die';
10  
11 1 ▶sub import { $complainmethod = 'warn_mode' if defined $_[1] and $_[1] eq 'warn'}
Subroutine import: called CC=3 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] and $_[1] eq "warn" 0 1 1
Condition33%1/3
defined $_[1] and $_[1] eq "warn"
!ll&&!rl&&r
100
MC/DC0%0/2
defined $_[1] and $_[1] eq "warn"
defined $_[1] $_[1] eq "warn"
Truth table33%1/3
A and B
A= defined $_[1]B= $_[1] eq "warn"
ABresult
0X0
100
111
12 0 ▶sub die_mode { $complainmethod = 'die'}
Subroutine die_mode: not called CC=1 SCAR=6.9
Pod undocumented
13 0 ▶sub warn_mode{ $complainmethod = 'warn'}
Subroutine warn_mode: not called CC=1 SCAR=6.9
Pod undocumented
14 0 ▶sub complain { $complainmethod eq 'die' ? die $_[0] : warn $_[0] }
Subroutine complain: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$Tie::Wx::Widget::complainmethod eq 'die' ? : 0 0 0
15  
16 0 ▶sub TIESCALAR {
Subroutine TIESCALAR: not called CC=12 SCAR=50.5
17 0 my ($self, $widget, $store, $fetch) = @_;
18  
19 0 ▶ if (not ref $widget) {complain("$widget isn't even a referece, has to a Wx object")}
Branch: 7 branches
BranchTrueFalseTotal
if (not ref $widget) { } 0 0 0
elsif (index($widget, '=') == -1) { } 0 0 0
elsif (not $widget->isa('Wx::Control')) { } 0 0 0
elsif (not $widget->can('GetValue')) { } 0 0 0
elsif (not $widget->can('SetValue')) { } 0 0 0
elsif (defined $store and ref $store ne 'CODE') { } 0 0 0
elsif (defined $fetch and ref $fetch ne 'CODE') { } 0 0 0
20 0 elsif (index($widget, '=') == -1) {complain("$widget isn't even an object, has to a Wx object")}
21 0 elsif (not $widget->isa('Wx::Control')) {complain("$widget is no Wx widget")}
22 0 elsif (not $widget->can('GetValue')) {complain("$widget has no method: GetValue")}
23 0 elsif (not $widget->can('SetValue')) {complain("$widget has no method: SetValue")}
24 0 ▶ elsif (defined $store and ref $store ne 'CODE'){complain("no coderef as STORE callback")}
Condition0%0/3
defined $store and ref $store ne "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $store and ref $store ne "CODE"
defined $store ref $store ne "CODE"
Truth table0%0/3
A and B
A= defined $storeB= ref $store ne "CODE"
ABresult
0X0
100
111
25 0 ▶ elsif (defined $fetch and ref $fetch ne 'CODE'){complain("no coderef as FETCH callback")}
Condition0%0/3
defined $fetch and ref $fetch ne "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fetch and ref $fetch ne "CODE"
defined $fetch ref $fetch ne "CODE"
Truth table0%0/3
A and B
A= defined $fetchB= ref $fetch ne "CODE"
ABresult
0X0
100
111
26 else {
27 0 my %hash = ('w' => $widget, 'widget' => $widget);
28 0 ▶ $hash{'store'} = $store if defined $store;
Branch: 1 branch
BranchTrueFalseTotal
if defined $store 0 0 0
29 0 ▶ $hash{'fetch'} = $fetch if defined $fetch;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fetch 0 0 0
30 0 return bless \%hash, $self;
31 }
32 0 return 0;
33 }
34 0 ▶sub FETCH {
Subroutine FETCH: not called CC=2 SCAR=17.9
35 0 ▶ if (exists $_[0]->{'fetch'}) { &{$_[0]->{'fetch'}}( $_[0]->{'w'} ) }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_[0]{'fetch'}) { } 0 0 0
36 0 else { return $_[0]->{'w'}->GetValue }
37 }
38 0 ▶sub STORE {
Subroutine STORE: not called CC=3 SCAR=24.8
39 0 ▶ return 0 if ref $_[1];
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[1] 0 0 0
40 0 ▶ if (exists $_[0]->{'store'}) { &{$_[0]->{'store'}}( $_[0]->{'w'}, $_[1] ) }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_[0]{'store'}) { } 0 0 0
41 0 else { return $_[0]->{'w'}->SetValue( $_[1] ) }
42 }
43 0 ▶sub UNTIE {} # to prevent crashes if called
Subroutine UNTIE: not called CC=1 SCAR=0.0
44 0 ▶sub DESTROY {} # to prevent crashes if called
Subroutine DESTROY: not called CC=1 SCAR=0.0
45  
46 1 'one';
47  
48 __END__
↑ Summary