IRC/Math.pm

filter: Statementstmt 77.7% 14 / 18 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 1 totaltotal 56.2% 18 / 32 CC 3 SCAR 16.4
CC
3
Cov
61%
__ANON__
12.0
init
1.3
BEGIN
1.0
CRAP 5.2
« IRC/Ping.pm ↑ Summary IRC/Seen.pm »
1 package Bot::IRC::Math;
2 # ABSTRACT: Bot::IRC evaluate math expressions and return results
3  
4 2 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use exact;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Math::Expression;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '1.49'; # VERSION
10  
11 1 ▶sub init {
Subroutine init: called CC=1 SCAR=2.9
Pod undocumented
12 1 my ($bot) = @_;
13 1 ▶ my $expr = Math::Expression->new( PrintErrFunc => sub {} );
Subroutine __ANON__: not called CC=1 SCAR=0.0
14  
15 $bot->hook(
16 {
17 command => 'PRIVMSG',
18 text => qr/^[\d\s\+\-\/\*\%\^\(\)]+$/,
19 },
20 0 ▶ sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
21 0 my ( $bot, $in ) = @_;
22 0 my $value = $expr->EvalToScalar( $expr->Parse( $in->{text} ) );
23 0 ( my $clean_text = $in->{text} ) =~ s/\s+//g;
24 0 ▶ $bot->reply($value) if ( $value and $value ne $clean_text );
Branch: 1 branch
BranchTrueFalseTotal
if $value and $value ne $clean_text 0 0 0
Condition0%0/3
$value and $value ne $clean_text
!ll&&!rl&&r
000
MC/DC0%0/2
$value and $value ne $clean_text
$value $value ne $clean_text
Truth table0%0/3
A and B
A= $valueB= $value ne $clean_text
ABresult
0X0
100
111
25 },
26 1 );
27  
28 1 $bot->helps( math => 'Evaluate math expressions. Usage: <math expression>.' );
29 }
30  
31 2 1;
32  
33 __END__
« IRC/Ping.pm ↑ Summary IRC/Seen.pm »