[Bps-public-commit] r16352 - in Path-Dispatcher/trunk: t
sartak at bestpractical.com
sartak at bestpractical.com
Sun Oct 19 04:25:34 EDT 2008
Author: sartak
Date: Sun Oct 19 04:25:33 2008
New Revision: 16352
Added:
Path-Dispatcher/trunk/t/014-tokens-prefix.t
Modified:
Path-Dispatcher/trunk/ (props changed)
Log:
r74106 at onn: sartak | 2008-10-19 04:25:27 -0400
Add tests for prefix matches
Added: Path-Dispatcher/trunk/t/014-tokens-prefix.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/014-tokens-prefix.t Sun Oct 19 04:25:33 2008
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+use Path::Dispatcher;
+
+my @calls;
+
+my $rule = Path::Dispatcher::Rule::Tokens->new(
+ tokens => ['foo', 'bar'],
+ block => sub { push @calls, [$1, $2, $3] },
+ prefix => 1,
+);
+
+ok(!$rule->match('foo'), "prefix means the rule matches a prefix of the path, not the other way around");
+ok($rule->match('foo bar'), "prefix matches the full path");
+ok($rule->match('foo bar baz'), "prefix matches a prefix of the path");
+
+is_deeply($rule->match('foo bar baz'), ["foo", "bar"], "match returns just the results");
+is_deeply([$rule->_match('foo bar baz')], [
+ ["foo", "bar"],
+ "baz"
+], "_match returns the results and the rest of the path");
+
More information about the Bps-public-commit
mailing list