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

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 29 15:45:52 EDT 2008


Author: sartak
Date: Tue Jul 29 15:45:50 2008
New Revision: 14616

Added:
   Path-Dispatcher/trunk/t/002-rule.t
Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/t/001-api.t

Log:
 r67898 at onn:  sartak | 2008-07-29 15:34:29 -0400
 Add more tests


Modified: Path-Dispatcher/trunk/t/001-api.t
==============================================================================
--- Path-Dispatcher/trunk/t/001-api.t	(original)
+++ Path-Dispatcher/trunk/t/001-api.t	Tue Jul 29 15:45:50 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 4;
+use Test::More tests => 8;
 use Path::Dispatcher;
 
 my @calls;
@@ -23,3 +23,19 @@
 $dispatcher->run('foo');
 is_deeply([splice @calls], [ [] ], "invoked the rule block on 'run'");
 
+$dispatcher->add_rule(
+    regex => qr/(bar)/,
+    block => sub { push @calls, [$1, $2] },
+);
+
+is_deeply([splice @calls], [], "no calls to the rule block yet");
+
+$thunk = $dispatcher->dispatch('bar');
+is_deeply([splice @calls], [], "no calls to the rule block yet");
+
+$thunk->();
+is_deeply([splice @calls], [ ['bar', undef] ], "finally invoked the rule block");
+
+$dispatcher->run('bar');
+is_deeply([splice @calls], [ ['bar', undef] ], "invoked the rule block on 'run'");
+

Added: Path-Dispatcher/trunk/t/002-rule.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/002-rule.t	Tue Jul 29 15:45:50 2008
@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Path::Dispatcher::Rule;
+
+my $rule = Path::Dispatcher::Rule->new(
+    regex => qr/^(..)(..)/,
+    block => sub {},
+);
+
+is_deeply([$rule->match('foobar')], [['fo', 'ob']]);
+



More information about the Bps-public-commit mailing list