[Bps-public-commit] r16914 - in Path-Dispatcher/trunk: t

sartak at bestpractical.com sartak at bestpractical.com
Tue Nov 18 19:39:32 EST 2008


Author: sartak
Date: Tue Nov 18 19:39:32 2008
New Revision: 16914

Added:
   Path-Dispatcher/trunk/t/017-intersection.t
Modified:
   Path-Dispatcher/trunk/   (props changed)

Log:
 r75779 at onn:  sartak | 2008-11-18 19:39:24 -0500
 Tests for intersections


Added: Path-Dispatcher/trunk/t/017-intersection.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/017-intersection.t	Tue Nov 18 19:39:32 2008
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+use Path::Dispatcher;
+
+my @calls;
+
+my $dispatcher = Path::Dispatcher->new(
+    rules => [
+        Path::Dispatcher::Rule::Intersection->new(
+            rules => [
+                Path::Dispatcher::Rule::Tokens->new(
+                    tokens => ['foo'],
+                    block => sub { push @calls, 'tokens' },
+                ),
+                Path::Dispatcher::Rule::Regex->new(
+                    regex => qr/^foo$/,
+                    block => sub { push @calls, 'regex' },
+                ),
+            ],
+            block => sub { push @calls, 'intersection' },
+        ),
+    ],
+);
+
+$dispatcher->run("foo");
+is_deeply([splice @calls], ['intersection'], "the intersection matched; doesn't automatically run the subrules");
+
+$dispatcher->run("food");
+is_deeply([splice @calls], [], "each subrule of the intersection must match");
+
+$dispatcher->run(" foo ");
+is_deeply([splice @calls], [], "each subrule of the intersection must match");
+



More information about the Bps-public-commit mailing list