Branch Coverage

blib/lib/RiveScript.pm
Criterion Covered Total %
branch 365 682 53.5


line true false branch
182 4 5 if ($action eq 'load') { }
5 0 elsif ($action eq 'call') { }
190 1 3 if ($@) { }
202 4 1 if (exists $rs->{'objects'}{$name}) { }
215 0 26 if (exists $self->{'verbose'})
218 0 26 if (exists $self->{'debugfile'})
229 48 3273 if ($self->{'debug'})
231 48 0 if ($self->{'debugopts'}{'verbose'})
236 0 48 if (length $self->{'debugopts'}{'file'})
249 0 3 if ($self->{'debug'}) { }
280 0 0 unless (-d $dir)
290 0 0 if $file eq '.'
291 0 0 if $file eq '..'
292 0 0 if $file =~ /\~$/i
296 0 0 if $file =~ /$re$/
298 0 0 unless $goodExt
320 0 0 unless (defined $file)
325 0 0 unless (-f $file)
355 0 29 unless (defined $code)
415 15 311 if ($inobj)
416 6 9 if ($line =~ /^<\s*object/i) { }
418 4 2 if (length $objname)
420 4 0 if (exists $self->{'handlers'}{$objlang}) { }
439 8 309 if ($line =~ m[^(//|#)]i) { }
0 309 elsif ($line =~ m[^/\*]) { }
0 309 elsif ($line =~ m[\*/]) { }
441 0 8 if ($line =~ /^#/)
447 0 0 if ($line =~ m[\*/])
460 0 309 if ($comment)
465 58 251 if length $line == 0
476 87 164 if ($cmd eq '+') { }
478 0 87 if ($line =~ /\s\s#\s/)
484 0 164 if ($line =~ /\s#\s/)
489 0 251 if ($line =~ /$inline_comment_regexp/)
500 0 251 if ($syntax_error)
503 0 0 if ($self->{'strict'}) { }
515 87 164 if ($cmd eq '+')
527 234 33 if (defined $lookahead and length $lookahead > 0)
529 211 23 if ($lookCmd ne '^' and $lookCmd ne '%')
536 7 16 if ($cmd eq '+')
538 7 0 if ($lookCmd eq '%') { }
552 1 15 if ($cmd eq '!')
553 1 0 if ($lookCmd eq '^')
565 11 4 if ($cmd ne '^' and $lookCmd ne '%')
566 11 0 if ($lookCmd eq '^') { }
569 10 1 exists $concat_mode{$local_options{'concat'}} ? :
580 17 234 if ($cmd eq '!') { }
16 218 elsif ($cmd eq '>') { }
16 202 elsif ($cmd eq '<') { }
87 115 elsif ($cmd eq '+') { }
83 32 elsif ($cmd eq '-') { }
7 25 elsif ($cmd eq '%') { }
12 13 elsif ($cmd eq '^') { }
3 10 elsif ($cmd eq '@') { }
10 0 elsif ($cmd eq '*') { }
588 16 1 if ($type ne 'array')
592 0 17 if ($type eq 'version') { }
5 12 elsif ($type eq 'local') { }
1 11 elsif ($type eq 'global') { }
2 9 elsif ($type eq 'var') { }
1 8 elsif ($type eq 'array') { }
6 2 elsif ($type eq 'sub') { }
2 0 elsif ($type eq 'person') { }
594 0 0 if ($value > $SUPPORT)
604 0 1 unless (defined $var)
608 0 1 unless (defined $value)
618 0 20 if ($var eq $res)
624 1 0 if ($ok) { }
626 0 1 if ($value eq '') { }
635 0 0 if ($value eq '') { }
645 0 2 unless (defined $var)
649 0 2 unless (defined $value)
654 0 2 if ($value eq '') { }
663 0 1 unless (defined $var)
667 0 1 unless (defined $value)
672 0 1 if ($value eq '')
685 1 1 if ($val =~ /\|/) { }
702 0 6 unless (defined $var)
706 0 6 unless (defined $value)
711 0 6 if ($value eq '')
719 0 2 unless (defined $var)
723 0 2 unless (defined $value)
727 0 2 if ($value eq '')
744 3 13 if ($type eq 'begin')
750 10 6 if ($type eq 'topic')
758 4 6 if (scalar @fields >= 2)
760 2 7 if ($field eq 'includes') { }
2 5 elsif ($field eq 'inherits') { }
5 0 elsif ($mode ne '') { }
768 3 2 if ($mode eq 'includes') { }
778 6 10 if ($type eq 'object')
780 5 1 scalar @fields ? :
785 1 5 unless (length $lang)
791 4 2 if (exists $self->{'handlers'}{$lang}) { }
811 10 6 if ($type eq 'begin' or $type eq 'topic') { }
6 0 elsif ($type eq 'object') { }
823 7 80 if (length $isThat) { }
839 0 83 if ($ontrig eq '')
844 7 76 if (length $isThat) { }
868 0 3 if (length $isThat) { }
878 0 10 if (length $isThat) { }
916 17 234 if ($cmd eq '!') { }
16 218 elsif ($cmd eq '>') { }
97 121 elsif ($cmd eq '+' or $cmd eq '%' or $cmd eq '@') { }
95 26 elsif ($cmd eq '-' or $cmd eq '^' or $cmd eq '/') { }
10 16 elsif ($cmd eq '*') { }
924 0 17 unless ($line =~ /^.+(?:\s+.+|)\s*=\s*.+?$/)
933 0 16 if ($line =~ /^begin/ and $line =~ /\s+/) { }
0 16 elsif ($line =~ /^topic/i and $line =~ /[^a-z0-9_\-\s]/) { }
0 16 elsif ($line =~ /[^A-Za-z0-9_\-\s]/) { }
956 15 82 if ($self->{'utf8'}) { }
958 0 15 if ($line =~ /[A-Z\\.]/)
963 0 82 if ($line =~ /[^a-z0-9(\|)\[\]*_#\@{}<>=\s]/)
974 6 1246 if $char eq '('
6 1246 if $char eq ')'
975 4 1248 if $char eq '['
4 1248 if $char eq ']'
976 3 1249 if $char eq '{'
3 1249 if $char eq '}'
977 0 1252 if $char eq '<'
0 1252 if $char eq '>'
981 0 97 if ($parens)
982 0 0 $parens > 0 ? :
984 0 97 if ($square)
985 0 0 $square > 0 ? :
987 0 97 if ($curly)
988 0 0 $curly > 0 ? :
990 0 97 if ($chevron)
991 0 0 $chevron > 0 ? :
1002 0 10 unless ($line =~ /^.+?\s*(==|eq|!=|ne|<>|<|<=|>|>=)\s*.+?=>.+?$/)
1028 29 29 if ($thats eq 'thats') { }
1053 3 103 if ($trig =~ /\{weight=(\d+)\}/i) { }
1056 3 0 unless (exists $prior->{$weight})
1114 10 96 if ($trig =~ /{inherits=(\d+)}/) { }
1116 4 6 if ($inherits > $highest_inherits)
1128 5 101 unless (exists $track->{$inherits})
1141 1 105 if ($trig =~ /\_/) { }
2 103 elsif ($trig =~ /\#/) { }
22 81 elsif ($trig =~ /\*/) { }
3 78 elsif ($trig =~ /\[(.+?)\]/) { }
1146 1 0 if ($cnt > 1) { }
1147 1 0 unless (exists $track->{$inherits}{'alpha'}{$cnt})
1161 2 0 if ($cnt > 1) { }
1162 2 0 unless (exists $track->{$inherits}{'number'}{$cnt})
1176 15 7 if ($cnt > 1) { }
1177 14 1 unless (exists $track->{$inherits}{'wild'}{$cnt})
1191 2 1 unless (exists $track->{$inherits}{'option'}{$cnt})
1201 54 24 unless (exists $track->{$inherits}{'atomic'}{$cnt})
1230 29 29 if ($thats ne 'thats')
1305 0 7 if ($trig =~ /\_/) { }
0 7 elsif ($trig =~ /\#/) { }
4 3 elsif ($trig =~ /\*/) { }
0 3 elsif ($trig =~ /\[(.+?)\]/) { }
1309 0 0 if ($cnt > 1) { }
1310 0 0 unless (exists $track->{'alpha'}{$cnt})
1323 0 0 if ($cnt > 1) { }
1324 0 0 unless (exists $track->{'number'}{$cnt})
1337 0 4 if ($cnt > 1) { }
1338 0 0 unless (exists $track->{'wild'}{$cnt})
1351 0 0 unless (exists $track->{'option'}{$cnt})
1360 3 0 unless (exists $track->{'atomic'}{$cnt})
1398 6 52 if (exists $self->{'sortlist'}{$name})
1415 4 4 unless (exists $track->{$cword})
1438 0 37 if ($depth > $self->{'depth'})
1449 12 25 if (exists $self->{'includes'}{$topic})
1459 5 32 if (exists $self->{'lineage'}{$topic})
1478 0 48 if ($depth > $self->{'depth'})
1505 3 45 if (exists $self->{'includes'}{$topic})
1514 2 46 if (exists $self->{'lineage'}{$topic})
1525 6 42 if (exists $self->{'lineage'}{$topic} or $inherited) { }
1612 0 0 if ($@)
1637 0 0 if ($self->{'debug'})
1640 0 0 if ($self->{'depth'} != 50)
1655 0 0 if ($topic eq '__begin__') { }
1661 0 0 unless (exists $deparse->{'topic'}{$topic})
1678 0 0 if ($topic eq '__begin__') { }
1684 0 0 unless (exists $deparse->{'that'}{$topic})
1720 0 0 if (exists $src->{'redirect'})
1723 0 0 if (exists $src->{'condition'})
1729 0 0 if (exists $src->{'reply'})
1741 0 0 if ($self->{'_can_clone'})
1768 0 0 if (ref $file eq 'GLOB') { }
0 0 elsif (ref $file) { }
1775 0 0 unless open $fh, '>', $file
1778 0 0 ref $deparsed ? :
1786 0 0 unless scalar keys %{$$deparse{'begin'}{$sort};} > 0
1790 0 0 if (ref $data eq 'ARRAY')
1793 0 0 if ($test =~ /\s+/)
1803 0 0 if ($needs_pipes) { }
1815 0 0 if (scalar keys %{$$deparse{'begin'}{'triggers'};})
1826 0 0 unless exists $deparse->{'topic'}{$topic}
1827 0 0 if $topic eq 'random' and $doneRandom
1828 0 0 if $topic eq 'random'
1832 0 0 if ($topic ne 'random' or exists $deparse->{'include'}{$topic} or exists $deparse->{'inherit'}{$topic})
1836 0 0 if (exists $deparse->{'inherit'}{$topic})
1839 0 0 if (exists $deparse->{'include'}{$topic})
1846 0 0 $tagged ? :
1849 0 0 if (exists $deparse->{'that'}{$topic})
1850 0 0 $tagged ? :
1853 0 0 if ($tagged)
1864 0 0 $id ? :
1870 0 0 if (exists $d->{'previous'})
1874 0 0 if (exists $d->{'condition'})
1880 0 0 if (exists $d->{'redirect'})
1884 0 0 if (exists $d->{'reply'})
1898 0 0 $indent ? :
1901 0 0 if ($sep eq ' ') { }
0 0 elsif ($sep eq '|') { }
1914 0 0 if (length $line > $width)
1924 0 0 if ($line)
1929 0 0 if (scalar @lines)
1930 0 0 $sep eq ' ' ? :
1988 1 26 if (not defined $code) { }
1993 26 0 if (ref $code eq 'CODE') { }
2039 0 0 unless (defined $data{$key})
2045 0 0 if ($res eq $key)
2051 0 0 if ($reserved) { }
2052 0 0 if ($data{$key} eq '') { }
2060 0 0 if ($data{$key} eq '') { }
2084 0 0 unless (defined $data{$key})
2088 0 0 if ($data{$key} eq '') { }
2117 0 0 unless (defined $data{$key})
2121 0 0 if ($data{$key} eq '') { }
2142 0 0 unless (defined $data{$key})
2146 0 0 if ($data{$key} eq '') { }
2170 0 7 unless (defined $data{$key})
2174 0 7 if ($data{$key} eq '') { }
2213 0 3 unless defined $user
2214 0 3 unless defined $var
2217 3 0 if (length $user and length $var)
2218 2 1 if (exists $self->{'client'}{$user}{$var}) { }
2226 0 0 if (length $user) { }
2245 0 0 if (length $user) { }
2274 0 0 unless defined $user
2276 0 0 if (length $user and exists $self->{'client'}{$user})
2279 0 0 if (exists $self->{'frozen'}{$user})
2285 0 0 if $var eq '__history__'
2331 0 0 unless defined $user
2333 0 0 if (length $user and exists $self->{'frozen'}{$user})
2337 0 0 if (exists $args{'discard'}) { }
0 0 elsif (exists $args{'keep'}) { }
2349 0 0 if ($restore)
2355 0 0 if $var eq '__history__'
2370 0 0 if ($discard)
2392 0 0 unless defined $user
2395 0 0 if (length $user and exists $self->{'client'}{$user}{'__lastmatch__'})
2419 0 0 unless (defined $self->{'current_user'})
2459 5 153 if (exists $self->{'topics'}{'__begin__'}{'request'}) { }
2467 4 1 if ($begin =~ /\{ok\}/i)
2509 0 216 if (scalar keys %{$$self{'sorted'};} == 0)
2519 191 25 if (exists $self->{'client'}{$user}) { }
2527 0 216 unless (exists $self->{'topics'}{$topic})
2534 1 215 if ($tags{'step'} > $self->{'depth'})
2536 1 0 if (exists $self->{'syntax'}{$topic}{$msg}{'ref'})
2544 5 210 if ($tags{'context'} eq 'begin')
2550 26 189 unless (exists $self->{'client'}{$user}{'__history__'})
2572 162 53 if ($tags{'step'} == 0)
2574 14 148 if (exists $self->{'includes'}{$topic} or exists $self->{'lineage'}{$topic})
2579 13 172 if (exists $self->{'sortsthat'}{$top})
2583 13 0 if (scalar @{$self->{'client'}{$user}{'__history__'}{'reply'};} > 0)
2598 7 35 if ($lastReply =~ /^$botside$/i)
2606 7 0 if ($msg =~ /^$humanside$/i)
2620 7 35 if $foundMatch
2626 7 178 if $foundMatch
2631 208 7 unless ($foundMatch)
2638 190 242 if ($msg =~ /^$regexp$/i)
2643 181 9 if (exists $self->{'topics'}{$topic}{$trig}) { }
2668 52 163 if (exists $matched->{'redirect'})
2681 15 148 if (exists $matched->{'condition'})
2694 0 39 if $left eq ''
2695 0 39 if $right eq ''
2701 19 20 if ($eq eq 'eq' or $eq eq '==') { }
4 16 elsif ($eq eq 'ne' or $eq eq '!=' or $eq eq '<>') { }
1 15 elsif ($eq eq '<') { }
0 15 elsif ($eq eq '<=') { }
7 8 elsif ($eq eq '>') { }
8 0 elsif ($eq eq '>=') { }
2702 4 15 if ($left eq $right)
2707 2 2 if ($left ne $right)
2712 1 0 if ($left < $right)
2717 0 0 if ($left <= $right)
2722 1 6 if ($left > $right)
2727 4 4 if ($left >= $right)
2732 12 27 if ($match)
2739 12 151 if length $reply > 0
2747 0 133 if ($text =~ /{weight=(\d+)\}/i)
2749 0 0 if ($weight <= 0)
2765 18 197 if ($foundMatch == 0) { }
0 197 elsif (not defined $reply or length $reply == 0) { }
2775 5 210 if ($tags{'context'} eq 'begin') { }
2776 0 5 if ($reply =~ /\{topic=(.+?)\}/i)
2807 0 13 if ($depth > $self->{'depth'})
2814 3 10 if (exists $self->{'lineage'}{$topic})
2817 1 2 if (exists $self->{'topics'}{$inherits}{$trig}) { }
2826 2 0 if (defined $match)
2835 8 2 if (exists $self->{'includes'}{$topic})
2839 8 2 if (exists $self->{'topics'}{$includes}{$trig}) { }
2848 0 2 if (defined $match)
2898 16 0 if (exists $self->{'arrays'}{$name})
2908 0 0 if (exists $self->{'bot'}{$var})
2920 0 0 if (exists $self->{'client'}{$user}{$var})
2929 0 481 if ($regexp =~ /
2941 0 481 if ($regexp =~ /
2963 23 322 if (scalar @stars == 1)
2966 338 7 if (scalar @botstars == 1)
2988 345 0 if (scalar @stars > 0)
2989 345 0 if defined $stars[1]
2990 10 0 defined $stars[$1] ? :
2992 345 0 if (scalar @botstars > 0)
2994 0 0 defined $botstars[$1] ? :
3009 0 0 if ($rand =~ /\|/) { }
3060 69 345 if ($reply =~ /<([^<]+?)>/) { }
3068 8 61 if ($tag eq 'bot' or $tag eq 'env') { }
12 49 elsif ($tag eq 'set') { }
0 49 elsif ($tag =~ /^(?:add|sub|mult|div)$/) { }
45 4 elsif ($tag eq 'get') { }
3072 3 5 if ($tag eq 'env')
3076 0 60 if ($res eq $what)
3081 0 3 if ($reserved) { }
3090 2 6 if ($data =~ /=/) { }
3095 5 1 exists $target->{$what} ? :
3108 0 0 unless (exists $self->{'client'}{$user}{$var})
3113 0 0 if (not $self->{'client'}{$user}{$var} =~ /^[0-9\-\.]+$/) { }
0 0 elsif ($value =~ /^[^0-9\-\.]$/) { }
3121 0 0 if ($tag eq 'add') { }
0 0 elsif ($tag eq 'sub') { }
0 0 elsif ($tag eq 'mult') { }
0 0 elsif ($tag eq 'div') { }
3132 0 0 if ($value == 0) { }
3142 39 6 exists $self->{'client'}{$user}{$data} ? :
3160 2 343 if ($reply =~ /\{topic=(.+?)\}/i)
3183 5 2 exists $self->{'objlangs'}{$obj} ? :
3184 5 2 if (length $lang) { }
3186 5 0 if (exists $self->{'handlers'}{$lang}) { }
3236 24 147 if ($self->{'utf8'}) { }
3242 9 15 if ($botReply)
3250 24 147 if ($self->{'utf8'}) { }
3268 3 2 if ($type eq 'formal') { }
2 0 elsif ($type eq 'sentence') { }
0 0 elsif ($type eq 'upper') { }
0 0 elsif ($type eq 'lower') { }