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

sartak at bestpractical.com sartak at bestpractical.com
Wed Oct 29 21:19:32 EDT 2008


Author: sartak
Date: Wed Oct 29 21:19:32 2008
New Revision: 16619

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/t/004-run.t

Log:
 r74851 at onn:  sartak | 2008-10-29 21:19:23 -0400
 Make tests work!


Modified: Path-Dispatcher/trunk/t/004-run.t
==============================================================================
--- Path-Dispatcher/trunk/t/004-run.t	(original)
+++ Path-Dispatcher/trunk/t/004-run.t	Wed Oct 29 21:19:32 2008
@@ -1,34 +1,39 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 1;
+use Test::More tests => 4;
 use Path::Dispatcher;
 
 my $dispatcher = Path::Dispatcher->new(
     rules => [
-        Path::Dispatcher::Rule::Tokens->new(
-            tokens => ['foo'],
-            block  => sub { "foo matched" },
+        Path::Dispatcher::Rule::Regex->new(
+            regex => qr/^foobar/,
+            block => sub { "foobar matched" },
         ),
     ],
 );
 
-my $result = $dispatcher->run("foo");
-is($result, "foo matched");
+my $result = $dispatcher->run("foobar");
+is($result, "foobar matched");
 
 $dispatcher->add_rule(
-    Path::Dispatcher::Rule::Tokens->new(
-        tokens => ['foo', 'bar'],
-        block  => sub { "foobar matched" },
+    Path::Dispatcher::Rule::Regex->new(
+        regex => qr/^foo/,
+        block => sub { "foo matched" },
     ),
 );
 
-$result = $dispatcher->run("foo bar");
+$result = $dispatcher->run("foobar");
 is($result, "foobar matched");
 
-$result = $dispatcher->run("foo");
-is($result, "foo matched");
+my $dispatch = $dispatcher->dispatch("foobar");
+for my $match ($dispatch->matches) {
+    $match->ends_dispatch(0);
+}
+
+$result = $dispatch->run("foobar");
+is($result, "foobar matched");
 
-my @results = $dispatcher->run("foo");
-is_deeply(\@results, ["foo matched", "foobar matched"]);
+my @results = $dispatch->run("foobar");
+is_deeply(\@results, ["foobar matched", "foo matched"]);
 



More information about the Bps-public-commit mailing list