Branch Coverage

blib/lib/PAGI/App/Router.pm
Criterion Covered Total %
branch 116 136 85.2


line true false branch
108 3 17 if (builtin::blessed($app_or_router) and $app_or_router->isa("PAGI::App::Router"))
139 4 1 if (@rest >= 2 and not ref $rest[-2] and $rest[-2] eq "method")
144 4 6 if (ref $method eq "ARRAY")
159 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) { }
180 1 2 unless eval "require $pkg; 1"
182 1 1 unless $pkg->can("router")
184 0 1 unless builtin::blessed($router_obj) and $router_obj->isa("PAGI::App::Router")
201 6 15 @new_names ? :
276 6 157 $method eq '*' ? :
4 163 ref $method eq 'ARRAY' ? :
303 11 245 if ($remaining =~ s/^\{(\w+):([^}]+)\}//) { }
2 243 elsif ($remaining =~ s/^\{(\w+)\}//) { }
3 240 elsif ($remaining =~ s/^\*(\w+)//) { }
48 192 elsif ($remaining =~ s/^:(\w+)//) { }
192 0 elsif ($remaining =~ s/^([^{:*]+)//) { }
342 13 15 unless $value =~ /^(?:$pattern)$/
355 2 40 unless $self->{'_last_route'}
356 1 39 unless defined $name and length $name
357 1 38 if exists $self->{'_named_routes'}{$name}
373 1 8 unless $self->{'_last_route'}
380 1 7 unless ref $pattern eq "Regexp"
391 0 9 unless defined $namespace and length $namespace
394 3 6 if ($self->{'_last_group_names'} and @{$self->{'_last_group_names'};})
399 0 5 if exists $self->{'_named_routes'}{$full_name}
408 2 4 unless $self->{'_last_mount'}
413 1 3 unless $sub_router
442 1 31 unless my $info = $self->{'_named_routes'}{$name}
450 1 15 unless (exists $path_params->{$param_name})
454 1 14 unless $path =~ s/:$param_name\b/$value/ or $path =~ s/\{$param_name(?::[^}]*)?\}/$value/
460 4 26 if $prefix
463 4 26 if (%$query_params)
490 6 5 if ($route->{'name'})
493 1 10 if ($route->{'_user_constraints'} and @{$route->{'_user_constraints'};})
506 0 0 if ($route->{'name'})
509 0 0 if ($route->{'_user_constraints'} and @{$route->{'_user_constraints'};})
522 0 0 if ($route->{'name'})
525 0 0 if ($route->{'_user_constraints'} and @{$route->{'_user_constraints'};})
535 57 177 if (@args == 2 and ref $args[0] eq 'ARRAY') { }
177 0 elsif (@args == 1) { }
554 44 5 if (ref $mw eq 'CODE') { }
2 3 elsif (builtin::blessed($mw) and $mw->can('call')) { }
572 119 42 unless $middlewares and @$middlewares
579 46 2 if (ref $mw eq 'CODE') { }
626 15 2 if ($path eq $prefix or $path =~ m[^\Q$prefix\E(/.*)$])
647 2 162 if $type eq "lifespan"
650 12 150 if ($type eq "websocket")
652 10 2 if (my(@captures) = $path =~ /$route->{'regex'}/)
659 1 9 unless $self->_check_constraints($route, \%params)
671 0 3 if (XXX)
675 0 3 if ($not_found) { }
689 10 140 if ($type eq "sse")
691 10 0 if (my(@captures) = $path =~ /$route->{'regex'}/)
698 1 9 unless $self->_check_constraints($route, \%params)
710 0 1 if (XXX)
714 0 1 if ($not_found) { }
729 2 138 $method eq 'HEAD' ? :
734 126 61 if (my(@captures) = $path =~ /$route->{'regex'}/)
743 11 115 unless $self->_check_constraints($route, \%params)
748 10 4 unless $_ eq $match_method
7 108 ref $route_method eq 'ARRAY' ? :
751 102 13 if ($method_match)
761 3 10 if (ref $route->{'method'} eq 'ARRAY') { }
10 0 elsif ($route->{'method'} ne '*') { }
770 8 30 if (@method_matches)
785 15 15 if (XXX)
790 0 15 if ($not_found) { }