eg/My/Macros.pm

filter: Statementstmt 64.8% 94 / 145 Branchbran 25.0% 7 / 28 Conditioncond 7.1% 1 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 72.2% 26 / 36 Podpod 0.0% 0 / 7 totaltotal 53.5% 128 / 239 CC 23 SCAR 26.2
CC
23
Cov
55%
test
72.0
operands
12.0
angle
10.7
CRAP 13.7
« blib/lib/Astro/App/Satpass2/Geocode.pm ↑ Summary blib/lib/Astro/App/Satpass2/ParseTime.pm »
1 package My::Macros;
2  
3 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use parent qw{ Astro::App::Satpass2 };
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Astro::App::Satpass2::Utils qw{ __arguments };
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Astro::Coord::ECI::Utils 0.059 qw{ rad2deg };
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Attribute::Handlers;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Scalar::Util 1.26 qw{ refaddr };
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our $VERSION = '0.059';
16  
17 {
18 1 my %operands;
19  
20 6 ▶ sub Operands : ATTR(CODE,RAWDATA) {
Subroutine Operands: called CC=1 SCAR=0.0
Pod undocumented
21 6 my ( undef, undef, $code, $name, $data ) = @_;
22 6 $operands{$code}{$name} = 0 + $data;
23 6 return;
24 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 0 ▶ sub operands {
Subroutine operands: not called CC=3 SCAR=24.8
Pod undocumented
27 0 my ( $code ) = @_;
28 0 ▶ return defined $code ? $operands{$code} || 0 : \%operands;
Branch: 1 branch
BranchTrueFalseTotal
defined $code ? : 0 0 0
Condition0%0/2
$operands{$code} or 0
l!l
00
MC/DC0%0/1
$operands{$code} or 0
$operands{$code}
Truth table0%0/2
A
A= $operands{$code}
Aresult
11
00
29 }
30 }
31  
32 1 ▶sub after_load : Verb() {
Subroutine after_load: not called CC=3 SCAR=22.3
Pod undocumented
33 0 my ( undef, $opt, @args ) = @_; # Invocant unused
34 0 my $rslt;
35 0 foreach my $key ( keys %{ $opt } ) {
36 0 $rslt .= "-$key $opt->{$key}\n";
37 }
38 0 foreach my $val ( @args ) {
39 0 $rslt .= "$val\n";
40 }
41 0 return $rslt;
42 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 2 ▶sub angle : Verb( radians! places=i ) {
Subroutine angle: called CC=9 SCAR=23.7
Pod undocumented
45 2 my ( $self, $opt, $name1, $name2, $time ) = __arguments( @_ );
46 2 $time = $self->__parse_time( $time, time );
47 2 ▶ defined $name1
Branch: 1 branch
BranchTrueFalseTotal
defined $name1 and defined $name2 or $self->wail("Two names or OIDs must be provided") 2 0 2
Condition33%1/3
defined $name1 and defined $name2
!ll&&!rl&&r
002
MC/DC0%0/2
defined $name1 and defined $name2
defined $name1 defined $name2
Truth table33%1/3
A and B
A= defined $name1B= defined $name2
ABresult
0X0
100
111
48 and defined $name2
49 or $self->wail( 'Two names or OIDs must be provided' );
50 2 my @things = $self->__choose(
51 { bodies => 1, sky => 1 },
52 [ $name1, $name2 ],
53 );
54 @things
55 2 ▶ or $self->wail( 'No bodies chosen' );
Branch: 1 branch
BranchTrueFalseTotal
@things or $self->wail("No bodies chosen") 2 0 2
56 2 ▶ @things < 2
Branch: 1 branch
BranchTrueFalseTotal
@things < 2 and $self->wail("Only 1 body (", $things[0]->get("name"), ") chosen") 0 2 2
57 and $self->wail( 'Only 1 body (',
58 $things[0]->get( 'name' ),
59 ') chosen' );
60 2 ▶ @things > 2
Branch: 1 branch
BranchTrueFalseTotal
@things > 2 and $self->wail(scalar @things, " bodies chosen") 0 2 2
61 and $self->wail( scalar @things, ' bodies chosen' );
62 2 my $station = $self->station()->universal( $time );
63 2 foreach my $body ( @things ) {
64 4 $body->universal( $time );
65 }
66 2 my $angle = $station->angle( @things );
67 $opt->{radians}
68 2 ▶ or $angle = rad2deg( $angle );
Branch: 1 branch
BranchTrueFalseTotal
$opt->{"radians"} or $angle = rad2deg($angle) 0 2 2
69 defined $opt->{places}
70 2 ▶ or return "$angle\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->{"places"} or return "$angle\n" 2 0 2
71 2 return sprintf "%.*f\n", $opt->{places}, $angle;
72 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
73  
74 1 ▶sub hi : Verb() {
Subroutine hi: called CC=2 SCAR=7.1
Pod undocumented
75 1 my ( undef, undef, $name ) = __arguments( @_ );
76 1 ▶ defined $name
Branch: 1 branch
BranchTrueFalseTotal
defined $name or $name = "world" 1 0 1
77 or $name = 'world';
78 1 return "Hello, $name!\n";
79 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
80  
81 {
82 my %operator = (
83 0 ▶ and => sub : Operands(2) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
84 0 my ( undef, $stack ) = @_; # Invocant unused
85 0 ▶ push @{ $stack }, pop @{ $stack } && pop @{ $stack };
Condition0%0/3
pop @{$stack;} && pop @{$stack;}
!ll&&!rl&&r
000
MC/DC0%0/2
pop @{$stack;} && pop @{$stack;}
pop @{$stack;} pop @{$stack;}
Truth table0%0/3
A && B
A= pop @{$stack;}B= pop @{$stack;}
ABresult
0X0
100
111
86 0 return;
87 1 ▶ },
Subroutine BEGIN: called CC=1 SCAR=0.0
88 0 ▶ choose => sub : Operands(1) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
89 0 my ( $self, $stack ) = @_;
90 # We want the number of bodies, but __choose(), for better
91 # or worse, provides a reference to the array of bodies in
92 # scalar context. So the empty parens provide list context
93 # to __choose(), hiding the fact that ultimately we do a
94 # scalar assign.
95 my $count = () = $self->__choose(
96 { bodies => 1 },
97 0 [ pop @{ $stack } ],
98 );
99 0 push @{ $stack }, $count;
100 0 return;
101 1 ▶ },
Subroutine BEGIN: called CC=1 SCAR=0.0
102 0 ▶ else => sub : Operands(1) {
Subroutine __ANON__: not called CC=1 SCAR=1.2
103 0 my ( undef, $stack ) = @_; # Invocant unused
104 0 $stack->[-1] = ! $stack->[-1];
105 1 ▶ no warnings qw{ exiting };
Subroutine BEGIN: called CC=1 SCAR=0.0
106 0 last TEST_LOOP;
107 1 ▶ },
Subroutine BEGIN: called CC=1 SCAR=0.0
108 0 ▶ not => sub : Operands(1) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
109 0 my ( undef, $stack ) = @_; # Invocant unused
110 0 $stack->[-1] = ! $stack->[-1];
111 0 return;
112 1 ▶ },
Subroutine BEGIN: called CC=1 SCAR=0.0
113 0 ▶ or => sub : Operands(2) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
114 0 my ( undef, $stack ) = @_; # Invocant unused
115 0 ▶ push @{ $stack }, pop @{ $stack } || pop @{ $stack };
Condition0%0/3
pop @{$stack;} || pop @{$stack;}
l!l&&r!l&&!r
000
MC/DC0%0/2
pop @{$stack;} || pop @{$stack;}
pop @{$stack;} pop @{$stack;}
Truth table0%0/3
A || B
A= pop @{$stack;}B= pop @{$stack;}
ABresult
1X1
011
000
116 0 return;
117 1 ▶ },
Subroutine BEGIN: called CC=1 SCAR=0.0
118 0 ▶ then => sub : Operands(1) {
Subroutine __ANON__: not called CC=1 SCAR=0.2
119 1 ▶ no warnings qw{ exiting };
Subroutine BEGIN: called CC=1 SCAR=0.0
120 0 last TEST_LOOP;
121 1 ▶ },
Subroutine BEGIN: called CC=1 SCAR=0.0
122 1 );
123  
124 0 ▶ sub test : Verb() {
Subroutine test: not called CC=8 SCAR=42.8
Pod undocumented
125 0 my ( $self, undef, @arg ) = __arguments( @_ );
126 0 my @stack;
127  
128 0 ▶ eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { TEST_LOOP: while (@arg) { my $current = shift @arg; if (my $code = $operator{$current}) { my $operands = operands($code); @stack >= $operands or $self->wail("Not enough operands. Need $operands"); &$code($self, \@stack); } else { push @stack, $current; } ; } ; 1 } } or $self->wail($@) 0 0 0
129 TEST_LOOP:
130 0 ▶ while ( @arg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@arg) 0 0 0
131 0 my $current = shift @arg;
132 0 ▶ if ( my $code = $operator{$current} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $operator{$current}) { } 0 0 0
133 0 my $operands = operands( $code );
134 0 ▶ @stack >= $operands
Branch: 1 branch
BranchTrueFalseTotal
@stack >= $operands or $self->wail("Not enough operands. Need $operands") 0 0 0
135 or $self->wail( "Not enough operands. Need $operands" );
136 0 $code->( $self, \@stack );
137 } else {
138 0 push @stack, $current;
139 }
140 }
141 0 1;
142 } or $self->wail( $@ );
143 0 ▶ @stack > 1
Branch: 1 branch
BranchTrueFalseTotal
@stack > 1 and $self->wail("More than one value left on stack") 0 0 0
144 and $self->wail( 'More than one value left on stack' );
145 0 ▶ $stack[-1]
Branch: 1 branch
BranchTrueFalseTotal
$stack[-1] and @arg or return 0 0 0
Condition0%0/3
$stack[-1] and @arg
!ll&&!rl&&r
000
MC/DC0%0/2
$stack[-1] and @arg
$stack[-1] @arg
Truth table0%0/3
A and B
A= $stack[-1]B= @arg
ABresult
0X0
100
111
146 and @arg
147 or return;
148 0 return $self->dispatch( @arg );
149 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
150 }
151  
152 1 ▶sub dumper : Verb() {
Subroutine dumper: not called CC=1 SCAR=0.4
Pod undocumented
153 0 my ( $self, @args ) = @_;
154 1 ▶ use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
155 0 return ref( $self ) . "\n" . Dump( \@args );
156 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
157  
158 1 1;
159  
160 __END__
« blib/lib/Astro/App/Satpass2/Geocode.pm ↑ Summary blib/lib/Astro/App/Satpass2/ParseTime.pm »