CljPerl/Atom.pm

filter: Statementstmt 75.9% 41 / 54 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 8 totaltotal 70.2% 59 / 84 CC 6 SCAR 7.5
CC
6
Cov
77%
show
6.0
new
2.0
type
2.0
CRAP 2.1
« CljPerl/Seq.pm ↑ Summary CljPerl/Logger.pm »
1 package CljPerl::Atom;
2
3 2 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 2 ▶ use CljPerl::Printer;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶ use CljPerl::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 2 our $VERSION = '0.10';
10 2 our $id = 0;
11
12 2332 ▶ sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
13 2332 my $class = shift;
14 2332 my $type = shift;
15 2332 my $value = shift;
16 2332 ▶ $value = "" if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1957 375 2332
17 2332 my $self = {class=>"Atom",
18 type=>$type,
19 value=>$value,
20 object_id=>"atom" . ($id++),
21 meta=>undef,
22 pos=>{filename=>"unknown",
23 line=>0,
24 col=>0}};
25 2332 bless $self;
26 2332 return $self;
27 }
28
29 2578 ▶ sub class {
Subroutine class: called CC=1 SCAR=0.0
Pod undocumented
30 2578 my $self = shift;
31 2578 return $self->{class};
32 }
33
34 4280 ▶ sub type {
Subroutine type: called CC=2 SCAR=6.9
Pod undocumented
35 4280 my $self = shift;
36 4280 my $type = shift;
37 4280 ▶ if(defined $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) { } 131 4149 4280
38 131 $self->{type} = $type;
39 } else {
40 4149 return $self->{type};
41 }
42 }
43
44 3 ▶ sub object_id {
Subroutine object_id: called CC=1 SCAR=0.0
Pod undocumented
45 3 my $self = shift;
46 3 return $self->{object_id};
47 }
48
49 20 ▶ sub meta {
Subroutine meta: called CC=2 SCAR=6.9
Pod undocumented
50 20 my $self = shift;
51 20 my $meta = shift;
52 20 ▶ if(defined $meta) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $meta) { } 6 14 20
53 6 $self->{meta} = $meta;
54 } else {
55 14 return $self->{meta};
56 }
57 }
58
59 4788 ▶ sub value {
Subroutine value: called CC=2 SCAR=6.9
Pod undocumented
60 4788 my $self = shift;
61 4788 my $value = shift;
62 4788 ▶ if(defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 33 4755 4788
63 33 $self->{value} = $value;
64 } else {
65 4755 return $self->{value};
66 }
67 }
68
69 0 ▶ sub show {
Subroutine show: not called CC=2 SCAR=17.9
Pod undocumented
70 0 my $self = shift;
71 0 my $indent = shift;
72 0 ▶ $indent = "" if !defined $indent;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $indent 0 0 0
73 #print $indent . "class: " . $self->{class} . "\n";
74 0 print $indent . "type: " . $self->{type} . "\n";
75 0 print $indent . "value: " . $self->{value} . "\n";
76 }
77
78 0 ▶ sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my $self = shift;
80 0 my $msg = shift;
81 0 $msg .= " [";
82 0 $msg .= CljPerl::Printer::to_string($self);
83 0 $msg .= "] @[file: " . $self->{pos}->{filename};
84 0 $msg .= " ;line: " . $self->{pos}->{line};
85 0 $msg .= " ;col: " . $self->{pos}->{col} . "]";
86 0 CljPerl::Logger::error($msg);
87 }
88
89 2 1;
90
« CljPerl/Seq.pm ↑ Summary CljPerl/Logger.pm »