Graph/Xmgrace/Axis_Option.pm

filter: Statementstmt 84.7% 39 / 46 Branchbran 70.0% 7 / 10 Conditioncond 54.5% 6 / 11 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 71.6% 58 / 81 CC 11 SCAR 16.1
CC
11
Cov
78%
print
7.1
AUTOLOAD
5.3
new
2.0
CRAP 5.0
« Graph/Xmgrace/Base_Option.pm ↑ Summary Graph/Xmgrace/Axis.pm »
1 #
2 # Chart::Graph::Xmgrace::Axis_Option.pm is a base class for all the axis options
3 #
4 ## This software product is developed by Esmond Lee and David Moore,
5 ## and copyrighted(C) 1998 by the University of California, San Diego
6 ## (UCSD), with all rights reserved. UCSD administers the CAIDA grant,
7 ## NCR-9711092, under which part of this code was developed.
8 ##
9 ## There is no charge for this software. You can redistribute it and/or
10 ## modify it under the terms of the GNU General Public License, v. 2 dated
11 ## June 1991 which is incorporated by reference herein. This software is
12 ## distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY
13 ## OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not
14 ## infringe on any third party's intellectual property rights.
15 ##
16 ## You should have received a copy of the GNU GPL along with this program.
17 ##
18 ##
19 ## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
20 ## PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
21 ## DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
22 ## SOFTWARE, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF
23 ## THE POSSIBILITY OF SUCH DAMAGE.
24 ##
25 ## THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
26 ## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
27 ## SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY
28 ## OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES
29 ## OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED
30 ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
31 ## PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE
32 ## ANY PATENT, TRADEMARK OR OTHER RIGHTS.
33 ##
34 ##
35 ## Contact: graph-dev@caida.org
36 ##
37 ##
38 4 $VERSION = 3.2;
39  
40 package Chart::Graph::Xmgrace::Axis_Option;
41 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 75 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
44 75 my $this = shift;
45 75 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0750
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
46 75 my $self = {};
47 75 bless $self, $class;
48 75 $self->_init(@_);
49 75 return $self;
50 }
51  
52 92 ▶sub _printline ($$$$ ) {
Subroutine _printline: called CC=1 SCAR=0.0
53 92 my $self = shift;
54 92 my ($handle, $string, $length) = @_;
55  
56 92 print $handle "@";
57 92 print $handle ' ' x $length;
58 92 print $handle "$string";
59  
60 92 return 1; # just for fun
61 }
62  
63 2 ▶sub print ($$$ ) {
Subroutine print: called CC=6 SCAR=19.6
Pod undocumented
64 2 my $self = shift;
65 2 my ($handle, $name) = @_;
66 2 my $string = "";
67 2 my $substr = "";
68  
69 2 foreach $option (@{ $self->{"print_order"} }) {
70 8 my $option_ref = $self->{"options"};
71  
72 8 ▶ if ($option eq "status" or $option eq "in_out_status") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option eq 'status' or $option eq 'in_out_status') { } 2 6 8
Condition66%2/3
$option eq "status" or $option eq "in_out_status"
l!l&&r!l&&!r
206
MC/DC50%1/2
$option eq "status" or $option eq "in_out_status"
$option eq "status" $option eq "in_out_status"
Truth table66%2/3
A or B
A= $option eq "status"B= $option eq "in_out_status"
ABresult
1X1
011
000
73
74 # we first check the status of the option, whether it's on/off
75 # if it's off, we don't print it out
76 2 ▶ if ($option_ref->{"status"} eq "off") {
Branch: 1 branch
BranchTrueFalseTotal
if ($option_ref->{"status"} eq "off") 0 2 2
77 0 $string = "$name $self->{name} $option_ref->{$option}\n";
78 0 $self->_printline($handle, $string, $self->{"length"});
79 0 last;
80 }
81 2 $string = "$name $self->{name} $option_ref->{$option}\n";
82 2 $self->_printline($handle, $string, $self->{"length"});
83  
84 } else {
85
86 # print function handles both scalars and lists
87 6 ▶ if (ref($option_ref->{$option}) eq ARRAY) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $option_ref->{$option} eq 'ARRAY') { } 0 6 6
88 0 $substr = join (", ", (@{ $option_ref->{$option} }));
89 0 $string = "$name $self->{name} $option $substr\n";
90 } else {
91 6 $string = "$name $self->{name} $option $option_ref->{$option}\n";
92 }
93 6 $self->_printline($handle, $string, $self->{"length"});
94 }
95 }
96 }
97  
98 91 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=16.6
99 91 my $self = shift;
100 91 ▶ my $type = ref($self) || croak "$self is not an object";
Condition50%1/2
ref $self || croak("$self is not an object")
l!l
910
MC/DC0%0/1
ref $self || croak("$self is not an object")
ref $self
Truth table50%1/2
A
A= ref $self
Aresult
11
00
101 91 my $name = $AUTOLOAD;
102 91 $name =~ s/.*://; #strip fully-qualified portion
103 91 ▶ unless (($name eq "DESTROY") or (exists $self->{options}->{$name})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name eq "DESTROY" or exists $self->{"options"}{$name}) 0 91 91
Condition66%2/3
$name eq "DESTROY" or exists $self->{"options"}{$name}
l!l&&r!l&&!r
69220
MC/DC0%0/2
$name eq "DESTROY" or exists $self->{"options"}{$name}
$name eq "DESTROY" exists $self->{"options"}{$name}
Truth table66%2/3
A or B
A= $name eq "DESTROY"B= exists $self->{"options"}{$name}
ABresult
1X1
011
000
104 0 croak "Can't access '$name' field in object of class $type";
105 }
106  
107 91 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 8 83 91
108 8 return $self->{options}->{$name} = shift;
109 } else {
110 83 return $self->{options}->{$name};
111 }
112 }
113  
114 4 1;
« Graph/Xmgrace/Base_Option.pm ↑ Summary Graph/Xmgrace/Axis.pm »