implement | dispatch combinator
[catagits/Web-Simple.git] / t / dispatch_parser.t
index 0a8b0cf..0e6a732 100644 (file)
@@ -40,6 +40,21 @@ is_deeply(
   '.xml does not match .html'
 );
 
+my $any_ext = $dp->parse_dispatch_specification('.*');
+
+is_deeply(
+  [ $any_ext->({ PATH_INFO => '/foo/bar.html' }) ],
+  [ { PATH_INFO => '/foo/bar' }, 'html' ],
+  '.html matches .* and extension returned'
+);
+
+is_deeply(
+  [ $any_ext->({ PATH_INFO => '/foo/bar' }) ],
+  [],
+  'no extension does not match .*'
+);
+
+
 my $slash = $dp->parse_dispatch_specification('/');
 
 is_deeply(
@@ -87,3 +102,20 @@ is_deeply(
   [],
   'POST /post/one does not match'
 );
+
+my $or = $dp->parse_dispatch_specification('GET|POST');
+
+foreach my $meth (qw(GET POST)) {
+
+  is_deeply(
+    [ $or->({ REQUEST_METHOD => $meth }) ],
+    [ {} ],
+    'GET|POST matches method '.$meth
+  );
+}
+
+is_deeply(
+  [ $or->({ REQUEST_METHOD => 'PUT' }) ],
+  [],
+  'GET|POST does not match PUT'
+);