Branch Coverage

blib/lib/PAGI/App/Router.pm
Criterion Covered Total %
branch 122 142 85.9


line true false branch
108 3 16 if (builtin::blessed($app_or_router) and $app_or_router->isa('PAGI::App::Router')) { }
4 12 elsif (not ref $app_or_router) { }
117 1 3 unless eval "require $pkg; 1"
119 1 2 unless $pkg->can("to_app")
152 4 1 if (@rest >= 2 and not ref $rest[-2] and $rest[-2] eq "method")
157 4 6 if (ref $method eq "ARRAY")
172 14 10 if (ref $target eq 'CODE') { }
6 4 elsif (builtin::blessed($target) and $target->isa('PAGI::App::Router')) { }
3 1 elsif (not ref $target) { }
193 1 2 unless eval "require $pkg; 1"
195 1 1 unless $pkg->can("router")
197 0 1 unless builtin::blessed($router_obj) and $router_obj->isa("PAGI::App::Router")
214 6 15 @new_names ? :
286 6 130 $method eq '*' ? :
4 136 ref $method eq 'ARRAY' ? :
313 11 213 if ($remaining =~ s/^\{(\w+):([^}]+)\}//) { }
2 211 elsif ($remaining =~ s/^\{(\w+)\}//) { }
3 208 elsif ($remaining =~ s/^\*(\w+)//) { }
45 163 elsif ($remaining =~ s/^:(\w+)//) { }
163 0 elsif ($remaining =~ s/^([^{:*]+)//) { }
352 13 15 unless $value =~ /^(?:$pattern)$/
365 2 40 unless $self->{'_last_route'}
366 1 39 unless defined $name and length $name
367 1 38 if exists $self->{'_named_routes'}{$name}
383 1 8 unless $self->{'_last_route'}
390 1 7 unless ref $pattern eq "Regexp"
401 0 9 unless defined $namespace and length $namespace
404 3 6 if ($self->{'_last_group_names'} and @{$self->{'_last_group_names'};})
409 0 5 if exists $self->{'_named_routes'}{$full_name}
418 2 4 unless $self->{'_last_mount'}
423 1 3 unless $sub_router
452 1 31 unless my $info = $self->{'_named_routes'}{$name}
460 1 15 unless (exists $path_params->{$param_name})
464 1 14 unless $path =~ s/:$param_name\b/$value/ or $path =~ s/\{$param_name(?::[^}]*)?\}/$value/
470 4 26 if $prefix
473 4 26 if (%$query_params)
499 6 5 if ($route->{'name'})
502 1 10 if ($route->{'_user_constraints'} and @{$route->{'_user_constraints'};})
515 0 0 if ($route->{'name'})
518 0 0 if ($route->{'_user_constraints'} and @{$route->{'_user_constraints'};})
531 0 0 if ($route->{'name'})
534 0 0 if ($route->{'_user_constraints'} and @{$route->{'_user_constraints'};})
544 37 167 if (@args == 2 and ref $args[0] eq 'ARRAY') { }
167 0 elsif (@args == 1) { }
563 24 5 if (ref $mw eq 'CODE') { }
2 3 elsif (builtin::blessed($mw) and $mw->can('call')) { }
581 109 22 unless $middlewares and @$middlewares
588 26 2 if (ref $mw eq 'CODE') { }
631 14 2 if ($path eq $prefix or $path =~ m[^\Q$prefix\E(/.*)$])
652 2 143 if $type eq "lifespan"
655 11 132 if ($type eq "websocket")
657 9 2 if (my(@captures) = $path =~ /$route->{'regex'}/)
664 1 8 unless $self->_check_constraints($route, \%params)
676 0 3 if (XXX)
680 0 3 if ($not_found) { }
694 9 123 if ($type eq "sse")
696 9 0 if (my(@captures) = $path =~ /$route->{'regex'}/)
703 1 8 unless $self->_check_constraints($route, \%params)
715 0 1 if (XXX)
719 0 1 if ($not_found) { }
734 2 121 $method eq 'HEAD' ? :
739 110 53 if (my(@captures) = $path =~ /$route->{'regex'}/)
748 11 99 unless $self->_check_constraints($route, \%params)
753 10 4 unless $_ eq $match_method
7 92 ref $route_method eq 'ARRAY' ? :
756 86 13 if ($method_match)
767 3 10 if (ref $route->{'method'} eq 'ARRAY') { }
10 0 elsif ($route->{'method'} ne '*') { }
776 8 29 if (@method_matches)
791 14 15 if (XXX)
796 0 15 if ($not_found) { }