implement ()
[catagits/Web-Simple.git] / t / dispatch_parser.t
index 0e6a732..7c5c0eb 100644 (file)
@@ -119,3 +119,46 @@ is_deeply(
   [],
   'GET|POST does not match PUT'
 );
+
+$or = $dp->parse_dispatch_specification('GET|POST|DELETE');
+
+foreach my $meth (qw(GET POST DELETE)) {
+
+  is_deeply(
+    [ $or->({ REQUEST_METHOD => $meth }) ],
+    [ {} ],
+    'GET|POST|DELETE matches method '.$meth
+  );
+}
+
+is_deeply(
+  [ $or->({ REQUEST_METHOD => 'PUT' }) ],
+  [],
+  'GET|POST|DELETE does not match PUT'
+);
+
+my $nest = $dp->parse_dispatch_specification('(GET+/foo)|POST');
+
+is_deeply(
+  [ $nest->({ PATH_INFO => '/foo', REQUEST_METHOD => 'GET' }) ],
+  [ {} ],
+  '(GET+/foo)|POST matches GET /foo'
+);
+
+is_deeply(
+  [ $nest->({ PATH_INFO => '/bar', REQUEST_METHOD => 'GET' }) ],
+  [],
+  '(GET+/foo)|POST does not match GET /bar'
+);
+
+is_deeply(
+  [ $nest->({ PATH_INFO => '/bar', REQUEST_METHOD => 'POST' }) ],
+  [ {} ],
+  '(GET+/foo)|POST matches POST /bar'
+);
+
+is_deeply(
+  [ $nest->({ PATH_INFO => '/foo', REQUEST_METHOD => 'PUT' }) ],
+  [],
+  '(GET+/foo)|POST does not match PUT /foo'
+);