[Bps-public-commit] Path-Dispatcher branch, master, updated. dcd650099fc6afc71200c3a7c135a7d1c68d1bca

Shawn Moore sartak at bestpractical.com
Tue Apr 19 17:14:25 EDT 2011


The branch, master has been updated
       via  dcd650099fc6afc71200c3a7c135a7d1c68d1bca (commit)
      from  34ea260d037f64cc75a6d27b1596c2be3058959a (commit)

Summary of changes:
 t/032-multiple-delimiter.t |   65 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 t/032-multiple-delimiter.t

- Log -----------------------------------------------------------------
commit dcd650099fc6afc71200c3a7c135a7d1c68d1bca
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Apr 19 17:14:18 2011 -0400

    Test for multiple delimiters in a row

diff --git a/t/032-multiple-delimiter.t b/t/032-multiple-delimiter.t
new file mode 100644
index 0000000..313632d
--- /dev/null
+++ b/t/032-multiple-delimiter.t
@@ -0,0 +1,65 @@
+use strict;
+use warnings;
+use Test::More;
+use Path::Dispatcher;
+
+my @calls;
+
+my $dispatcher = Path::Dispatcher->new;
+$dispatcher->add_rule(
+    Path::Dispatcher::Rule::Sequence->new(
+        delimiter => ' ',
+        rules => [
+            Path::Dispatcher::Rule::Eq->new(
+                string => 'foo',
+            ),
+            Path::Dispatcher::Rule::Eq->new(
+                string => 'bar',
+            ),
+        ],
+        block => sub { push @calls, shift->positional_captures },
+    ),
+);
+
+$dispatcher->run('foo bar');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+$dispatcher->run('foo    bar');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+$dispatcher->run('   foo    bar    ');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+
+$dispatcher = Path::Dispatcher->new;
+$dispatcher->add_rule(
+    Path::Dispatcher::Rule::Sequence->new(
+        delimiter => '/',
+        rules => [
+            Path::Dispatcher::Rule::Eq->new(
+                string => 'foo',
+            ),
+            Path::Dispatcher::Rule::Eq->new(
+                string => 'bar',
+            ),
+        ],
+        block => sub { push @calls, shift->positional_captures },
+    ),
+);
+
+$dispatcher->run('/foo/bar');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+$dispatcher->run('/foo/bar/');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+$dispatcher->run('/foo//bar/');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+$dispatcher->run('foo/bar');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+$dispatcher->run('///foo///bar///');
+is_deeply([splice @calls], [ ['foo', 'bar'] ], "correctly populated number vars from [str, str] token rule");
+
+done_testing;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list