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

sartak at bestpractical.com sartak at bestpractical.com
Wed Oct 29 21:06:38 EDT 2008


Author: sartak
Date: Wed Oct 29 21:06:38 2008
New Revision: 16616

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

Log:
 r74846 at onn:  sartak | 2008-10-29 21:05:05 -0400
 Add tests for run returning values


Added: Path-Dispatcher/trunk/t/004-run.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/004-run.t	Wed Oct 29 21:06:38 2008
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Path::Dispatcher;
+
+my $dispatcher = Path::Dispatcher->new(
+    rules => [
+        Path::Dispatcher::Rule::Tokens->new(
+            tokens => ['foo'],
+            block  => sub { "foo matched" },
+        ),
+    ],
+);
+
+my $result = $dispatcher->run("foo");
+is($result, "foo matched");
+
+$dispatcher->add_rule(
+    Path::Dispatcher::Rule::Tokens->new(
+        tokens => ['foo', 'bar'],
+        block  => sub { "foobar matched" },
+    ),
+);
+
+$result = $dispatcher->run("foo bar");
+is($result, "foobar matched");
+
+$result = $dispatcher->run("foo");
+is($result, "foo matched");
+
+my @results = $dispatcher->run("foo");
+is_deeply(\@results, ["foo matched", "foobar matched"]);
+



More information about the Bps-public-commit mailing list