[Bps-public-commit] r16673 - in Path-Dispatcher/trunk: lib/Path/Dispatcher/Rule t
sartak at bestpractical.com
sartak at bestpractical.com
Tue Nov 4 17:36:32 EST 2008
Author: sartak
Date: Tue Nov 4 17:36:32 2008
New Revision: 16673
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm
Path-Dispatcher/trunk/t/013-tokens.t
Path-Dispatcher/trunk/t/903-weird-token.t
Log:
r74962 at onn: sartak | 2008-11-03 22:36:30 -0500
Test coverage improvements
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm Tue Nov 4 17:36:32 2008
@@ -83,8 +83,9 @@
elsif ($RegexpRef->check($expected)) {
return $got =~ $expected;
}
-
- return 0;
+ else {
+ die "Unexpected token '$expected'"; # the irony is not lost on me :)
+ }
}
sub tokenize {
Modified: Path-Dispatcher/trunk/t/013-tokens.t
==============================================================================
--- Path-Dispatcher/trunk/t/013-tokens.t (original)
+++ Path-Dispatcher/trunk/t/013-tokens.t Tue Nov 4 17:36:32 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 11;
use Path::Dispatcher;
my @calls;
@@ -17,6 +17,8 @@
$dispatcher->run('foo bar');
is_deeply([splice @calls], [ ['foo', 'bar', undef] ], "correctly populated number vars from [str, str] token rule");
+ok(!$dispatcher->dispatch('foo bar baz')->has_match, "no match for 'foo bar baz' because the rule isn't a prefix");
+
$dispatcher->add_rule(
Path::Dispatcher::Rule::Tokens->new(
tokens => ['foo', qr/bar/],
Modified: Path-Dispatcher/trunk/t/903-weird-token.t
==============================================================================
--- Path-Dispatcher/trunk/t/903-weird-token.t (original)
+++ Path-Dispatcher/trunk/t/903-weird-token.t Tue Nov 4 17:36:32 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More tests => 2;
use Path::Dispatcher;
use Test::Exception;
@@ -11,3 +11,12 @@
)
} qr/^Attribute \(tokens\) does not pass the type constraint because: Validation failed for 'Path::Dispatcher::Tokens' failed with value ARRAY\(\w+\)/;
+my $rule = Path::Dispatcher::Rule::Tokens->new(
+ tokens => [],
+);
+
+push @{ $rule->{tokens} }, { weird_token => 1 };
+
+throws_ok {
+ $rule->match("mezzanine");
+} qr/^Unexpected token 'HASH\(\w+\)'/;
More information about the Bps-public-commit
mailing list