X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fdispatch_parser.t;h=b42bb61dbde91c08b34184af351f7fa133407e38;hb=cb12d2a32b35b292b35a9146d55a11f86db87954;hp=8405d7d8c82d25d70bf7645820a76abd6bcd1798;hpb=1c4f4b78368069e0c626aa5cd70c8fb55f594538;p=catagits%2FWeb-Simple.git diff --git a/t/dispatch_parser.t b/t/dispatch_parser.t index 8405d7d..b42bb61 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -23,17 +23,12 @@ my $dp = Web::Dispatch::Parser->new; ); } -ok( - !eval { $dp->parse('GET POST'); 1; }, - "Don't yet allow two methods" -); - { my $html = $dp->parse('.html'); is_deeply( [ $html->({ PATH_INFO => '/foo/bar.html' }) ], - [ { PATH_INFO => '/foo/bar' } ], + [ { } ], '.html matches' ); @@ -49,7 +44,7 @@ ok( is_deeply( [ $any_ext->({ PATH_INFO => '/foo/bar.html' }) ], - [ { PATH_INFO => '/foo/bar' }, 'html' ], + [ { }, 'html' ], '.html matches .* and extension returned' ); @@ -90,6 +85,12 @@ ok( [], '/post/one/ does not match' ); + + is_deeply( + [ $post->({ PATH_INFO => '/post/one.html' }) ], + [ {}, 'one' ], + '/post/one.html still parses out one' + ); } { @@ -219,7 +220,7 @@ ok( is_deeply( [ $not->({ PATH_INFO => '/foo.xml' }) ], - [ { PATH_INFO => '/foo' }, 'xml' ], + [ {}, 'xml' ], '!.html+.* matches /foo.xml' ); @@ -258,6 +259,23 @@ ok( ); } +{ + my @dot_pairs = ( + [ '/one/*' => 'two' ], + [ '/one/*.*' => 'two.three' ], + [ '/**' => 'one/two' ], + [ '/**.*' => 'one/two.three' ], + ); + + foreach my $p (@dot_pairs) { + is_deeply( + [ $dp->parse($p->[0])->({ PATH_INFO => '/one/two.three' }) ], + [ {}, $p->[1] ], + "${\$p->[0]} matches /one/two.three and returns ${\$p->[1]}" + ); + } +} + # # query string # @@ -314,7 +332,7 @@ foreach my $win ( [ '?:baz=&:evil=' => { baz => 'one two', evil => '/' } ], [ '?*' => \%all_single ], [ '?@*' => \%all_multi ], - [ '?foo=&@*' => 'FOO', do { my %h = %all_multi; delete $h{foo}; \%h } ], + [ '?foo=&@*' => 'FOO', \%all_multi ], [ '?:foo=&@*' => { %all_multi, foo => 'FOO' } ], [ '?:@bar=&*' => { %all_single, bar => [ qw(BAR1 BAR2) ] } ], ) { @@ -365,7 +383,7 @@ foreach my $win2 ( [ '/foo/bar/+?:baz=&:evil=' => { baz => 'one two', evil => '/' } ], [ '/foo/bar/+?*' => \%all_single ], [ '/foo/bar/+?@*' => \%all_multi ], - [ '/foo/bar/+?foo=&@*' => 'FOO', do { my %h = %all_multi; delete $h{foo}; \%h } ], + [ '/foo/bar/+?foo=&@*' => 'FOO', \%all_multi ], [ '/foo/bar/+?:foo=&@*' => { %all_multi, foo => 'FOO' } ], [ '/foo/bar/+?:@bar=&*' => { %all_single, bar => [ qw(BAR1 BAR2) ] } ], ) { @@ -416,7 +434,7 @@ foreach my $win3 ( [ '/foo/bar+?:baz=&:evil=' => { baz => 'one two', evil => '/' } ], [ '/foo/bar+?*' => \%all_single ], [ '/foo/bar+?@*' => \%all_multi ], - [ '/foo/bar+?foo=&@*' => 'FOO', do { my %h = %all_multi; delete $h{foo}; \%h } ], + [ '/foo/bar+?foo=&@*' => 'FOO', \%all_multi ], [ '/foo/bar+?:foo=&@*' => { %all_multi, foo => 'FOO' } ], [ '/foo/bar+?:@bar=&*' => { %all_single, bar => [ qw(BAR1 BAR2) ] } ], ) {