X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdispatch_parser.t;h=7b1632b1e859e4a273942bf2d666311cfdfa31f2;hb=b83ac30755e9f4c477759b0ab1d6550152d373d6;hp=8b6f4ab140ca58e154035687342053cc3fdb8a7c;hpb=a96dd5cb4a8216e60a9293aa537038c237819838;p=catagits%2FWeb-Simple.git diff --git a/t/dispatch_parser.t b/t/dispatch_parser.t index 8b6f4ab..7b1632b 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -329,6 +329,12 @@ my $dp = Web::Dispatch::Parser->new; my $sub = $dp->parse($match); is_deeply( + [ $sub->({ PATH_INFO => '/foobar' }) ], + [], + "$match does not match /foobar" + ); + + is_deeply( [ $sub->({ PATH_INFO => '/foo/bar' }) ], [ { PATH_INFO => '/bar', SCRIPT_NAME => '/foo' } ], "$match matches /foo/bar and strips to /bar" @@ -364,6 +370,24 @@ my $dp = Web::Dispatch::Parser->new; } } +{ + my @named = ( + [ '/foo/*:foo_id' => '/foo/1' => { foo_id => 1 } ], + [ '/foo/:foo_id' => '/foo/1' => { foo_id => 1 } ], + [ '/foo/:id/**:rest' => '/foo/id/rest/of/the/path.ext' + => { id => 'id', rest => 'rest/of/the/path' } ], + [ '/foo/:id/**.*:rest' => '/foo/id/rest/of/the/path.ext' + => { id => 'id', rest => 'rest/of/the/path.ext' } ], + ); + foreach my $n (@named) { + is_deeply( + [ $dp->parse($n->[0])->({ PATH_INFO => $n->[1] }) ], + [ {}, $n->[2] ], + "${\$n->[0]} matches ${\$n->[1]} with correct captures" + ); + } +} + # # query string #