2 use warnings FATAL => 'all';
4 use Test::More qw(no_plan);
6 use Web::Simple::DispatchParser;
8 my $dp = Web::Simple::DispatchParser->new;
10 my $get = $dp->parse_dispatch_specification('GET');
13 [ $get->({ REQUEST_METHOD => 'GET' }) ],
19 [ $get->({ REQUEST_METHOD => 'POST' }) ],
25 !eval { $dp->parse_dispatch_specification('GET POST'); 1; },
26 "Don't yet allow two methods"
29 my $html = $dp->parse_dispatch_specification('.html');
32 [ $html->({ PATH_INFO => '/foo/bar.html' }) ],
33 [ { PATH_INFO => '/foo/bar' } ],
38 [ $html->({ PATH_INFO => '/foo/bar.xml' }) ],
40 '.xml does not match .html'
43 my $slash = $dp->parse_dispatch_specification('/');
46 [ $slash->({ PATH_INFO => '/' }) ],
52 [ $slash->({ PATH_INFO => '/foo' }) ],
54 '/foo does not match /'
57 my $post = $dp->parse_dispatch_specification('/post/*');
60 [ $post->({ PATH_INFO => '/post/one' }) ],
62 '/post/one parses out one'
66 [ $post->({ PATH_INFO => '/post/one/' }) ],
68 '/post/one/ does not match'
71 my $combi = $dp->parse_dispatch_specification('GET+/post/*');
74 [ $combi->({ PATH_INFO => '/post/one', REQUEST_METHOD => 'GET' }) ],
76 '/post/one parses out one'
80 [ $combi->({ PATH_INFO => '/post/one/', REQUEST_METHOD => 'GET' }) ],
82 '/post/one/ does not match'
86 [ $combi->({ PATH_INFO => '/post/one', REQUEST_METHOD => 'POST' }) ],
88 'POST /post/one does not match'