Branch Coverage

blib/lib/PAGI/App/Router.pm
Criterion Covered Total %
branch 117 134 87.3


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 161 $method eq '*' ? :
4 167 ref $method eq 'ARRAY' ? :
303 11 249 if ($remaining =~ s/^\{(\w+):([^}]+)\}//) { }
2 247 elsif ($remaining =~ s/^\{(\w+)\}//) { }
3 244 elsif ($remaining =~ s/^\*(\w+)//) { }
48 196 elsif ($remaining =~ s/^:(\w+)//) { }
196 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 37 201 if (@args == 2 and ref $args[0] eq 'ARRAY') { }
201 0 elsif (@args == 1) { }
554 23 5 if (ref $mw eq 'CODE') { }
2 3 elsif (builtin::blessed($mw) and $mw->can('wrap')) { }
570 143 22 unless $middlewares and @$middlewares
574 25 2 ref $mw eq 'CODE' ? :
601 15 2 if ($path eq $prefix or $path =~ m[^\Q$prefix\E(/.*)$])
623 3 22 if ($not_found)
628 16 6 $type eq 'http' ? :
644 2 170 if $type eq "lifespan"
647 14 156 if ($type eq "websocket")
649 10 2 if (my(@captures) = $path =~ /$route->{'regex'}/)
656 1 9 unless $self->_check_constraints($route, \%params)
668 0 5 if (XXX)
677 12 144 if ($type eq "sse")
679 10 0 if (my(@captures) = $path =~ /$route->{'regex'}/)
686 1 9 unless $self->_check_constraints($route, \%params)
698 0 3 if (XXX)
708 2 142 $method eq 'HEAD' ? :
713 128 61 if (my(@captures) = $path =~ /$route->{'regex'}/)
722 11 117 unless $self->_check_constraints($route, \%params)
727 10 4 unless $_ eq $match_method
7 110 ref $route_method eq 'ARRAY' ? :
730 104 13 if ($method_match)
740 3 10 if (ref $route->{'method'} eq 'ARRAY') { }
10 0 elsif ($route->{'method'} ne '*') { }
749 8 32 if (@method_matches)
764 15 17 if (XXX)