[Bps-public-commit] r15110 - in Path-Dispatcher/trunk: lib/Path/Dispatcher t
sartak at bestpractical.com
sartak at bestpractical.com
Wed Aug 13 05:09:38 EDT 2008
Author: sartak
Date: Wed Aug 13 05:09:33 2008
New Revision: 15110
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
Path-Dispatcher/trunk/t/001-api.t
Path-Dispatcher/trunk/t/002-rule.t
Path-Dispatcher/trunk/t/003-404.t
Path-Dispatcher/trunk/t/004-stages.t
Path-Dispatcher/trunk/t/005-multi-rule.t
Path-Dispatcher/trunk/t/006-abort.t
Path-Dispatcher/trunk/t/007-coderef-matcher.t
Path-Dispatcher/trunk/t/008-super-dispatcher.t
Path-Dispatcher/trunk/t/009-args.t
Path-Dispatcher/trunk/t/010-return.t
Path-Dispatcher/trunk/t/101-subclass.t
Log:
r69452 at onn: sartak | 2008-08-13 05:08:38 -0400
Test fixes for the API change in add_rule
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm Wed Aug 13 05:09:33 2008
@@ -59,22 +59,28 @@
},
on => sub {
$dispatcher->add_rule(
- regex => $_[0],
- block => $_[1],
+ Path::Dispatcher::Rule::Regex->new(
+ regex => $_[0],
+ block => $_[1],
+ ),
);
},
before => sub {
$dispatcher->add_rule(
- stage => 'first',
- regex => $_[0],
- block => $_[1],
+ Path::Dispatcher::Rule::Regex->new(
+ stage => 'first',
+ regex => $_[0],
+ block => $_[1],
+ ),
);
},
after => sub {
$dispatcher->add_rule(
- stage => 'last',
- regex => $_[0],
- block => $_[1],
+ Path::Dispatcher::Rule::Regex->new(
+ stage => 'last',
+ regex => $_[0],
+ block => $_[1],
+ ),
);
},
};
Modified: Path-Dispatcher/trunk/t/001-api.t
==============================================================================
--- Path-Dispatcher/trunk/t/001-api.t (original)
+++ Path-Dispatcher/trunk/t/001-api.t Wed Aug 13 05:09:33 2008
@@ -8,8 +8,10 @@
my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
- regex => qr/foo/,
- block => sub { push @calls, [@_] },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/foo/,
+ block => sub { push @calls, [@_] },
+ ),
);
is_deeply([splice @calls], [], "no calls to the rule block yet");
@@ -25,8 +27,10 @@
is_deeply([splice @calls], [ [] ], "invoked the rule block on 'run'");
$dispatcher->add_rule(
- regex => qr/(bar)/,
- block => sub { push @calls, [$1, $2] },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/(bar)/,
+ block => sub { push @calls, [$1, $2] },
+ ),
);
is_deeply([splice @calls], [], "no calls to the rule block yet");
Modified: Path-Dispatcher/trunk/t/002-rule.t
==============================================================================
--- Path-Dispatcher/trunk/t/002-rule.t (original)
+++ Path-Dispatcher/trunk/t/002-rule.t Wed Aug 13 05:09:33 2008
@@ -6,7 +6,7 @@
my @calls;
-my $rule = Path::Dispatcher::Rule->new(
+my $rule = Path::Dispatcher::Rule::Regex->new(
regex => qr/^(..)(..)/,
block => sub {
push @calls, {
Modified: Path-Dispatcher/trunk/t/003-404.t
==============================================================================
--- Path-Dispatcher/trunk/t/003-404.t (original)
+++ Path-Dispatcher/trunk/t/003-404.t Wed Aug 13 05:09:33 2008
@@ -8,8 +8,10 @@
my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
- regex => qr/foo/,
- block => sub { push @calls, [@_] },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/foo/,
+ block => sub { push @calls, [@_] },
+ ),
);
my $dispatch = $dispatcher->dispatch('bar');
Modified: Path-Dispatcher/trunk/t/004-stages.t
==============================================================================
--- Path-Dispatcher/trunk/t/004-stages.t (original)
+++ Path-Dispatcher/trunk/t/004-stages.t Wed Aug 13 05:09:33 2008
@@ -14,9 +14,11 @@
: "${substage}_$stage";
$dispatcher->add_rule(
- stage => $qualified_stage,
- regex => qr/foo/,
- block => sub { push @calls, $qualified_stage },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => $qualified_stage,
+ regex => qr/foo/,
+ block => sub { push @calls, $qualified_stage },
+ ),
);
}
}
Modified: Path-Dispatcher/trunk/t/005-multi-rule.t
==============================================================================
--- Path-Dispatcher/trunk/t/005-multi-rule.t (original)
+++ Path-Dispatcher/trunk/t/005-multi-rule.t Wed Aug 13 05:09:33 2008
@@ -10,9 +10,11 @@
for my $stage (qw/first on last/) {
for my $number (qw/first second/) {
$dispatcher->add_rule(
- stage => $stage,
- regex => qr/foo/,
- block => sub { push @calls, "$stage: $number" },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => $stage,
+ regex => qr/foo/,
+ block => sub { push @calls, "$stage: $number" },
+ ),
);
}
}
Modified: Path-Dispatcher/trunk/t/006-abort.t
==============================================================================
--- Path-Dispatcher/trunk/t/006-abort.t (original)
+++ Path-Dispatcher/trunk/t/006-abort.t Wed Aug 13 05:09:33 2008
@@ -9,19 +9,23 @@
my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
- regex => qr/foo/,
- block => sub {
- push @calls, "on";
- die "Patch::Dispatcher abort\n";
- },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/foo/,
+ block => sub {
+ push @calls, "on";
+ die "Patch::Dispatcher abort\n";
+ },
+ ),
);
$dispatcher->add_rule(
- stage => 'last',
- regex => qr/foo/,
- block => sub {
- push @calls, "last";
- },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => 'last',
+ regex => qr/foo/,
+ block => sub {
+ push @calls, "last";
+ },
+ ),
);
my $dispatch;
@@ -36,12 +40,14 @@
is_deeply([splice @calls], ['on'], "correctly aborted the entire dispatch");
$dispatcher->add_rule(
- regex => qr/bar/,
- block => sub {
- push @calls, "bar: before";
- my $x = {}->();
- push @calls, "bar: last";
- },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/bar/,
+ block => sub {
+ push @calls, "bar: before";
+ my $x = {}->();
+ push @calls, "bar: last";
+ },
+ ),
);
throws_ok {
Modified: Path-Dispatcher/trunk/t/007-coderef-matcher.t
==============================================================================
--- Path-Dispatcher/trunk/t/007-coderef-matcher.t (original)
+++ Path-Dispatcher/trunk/t/007-coderef-matcher.t Wed Aug 13 05:09:33 2008
@@ -8,8 +8,10 @@
my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
- matcher => sub { push @matches, $_; length > 5 },
- block => sub { push @calls, [@_] },
+ Path::Dispatcher::Rule::CodeRef->new(
+ matcher => sub { push @matches, $_; length > 5 },
+ block => sub { push @calls, [@_] },
+ ),
);
$dispatcher->run('foobar');
Modified: Path-Dispatcher/trunk/t/008-super-dispatcher.t
==============================================================================
--- Path-Dispatcher/trunk/t/008-super-dispatcher.t (original)
+++ Path-Dispatcher/trunk/t/008-super-dispatcher.t Wed Aug 13 05:09:33 2008
@@ -19,17 +19,21 @@
for my $stage (qw/before_on on after_on/) {
$super_dispatcher->add_rule(
- stage => $stage,
- regex => qr/foo/,
- block => sub { push @calls, "super $stage" },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => $stage,
+ regex => qr/foo/,
+ block => sub { push @calls, "super $stage" },
+ ),
);
}
for my $stage (qw/before_on after_on/) {
$sub_dispatcher->add_rule(
- stage => $stage,
- regex => qr/foo/,
- block => sub { push @calls, "sub $stage" },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => $stage,
+ regex => qr/foo/,
+ block => sub { push @calls, "sub $stage" },
+ ),
);
}
@@ -50,9 +54,11 @@
]);
$sub_dispatcher->add_rule(
- stage => 'on',
- regex => qr/foo/,
- block => sub { push @calls, "sub on" },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => 'on',
+ regex => qr/foo/,
+ block => sub { push @calls, "sub on" },
+ ),
);
$sub_dispatcher->run('foo');
Modified: Path-Dispatcher/trunk/t/009-args.t
==============================================================================
--- Path-Dispatcher/trunk/t/009-args.t (original)
+++ Path-Dispatcher/trunk/t/009-args.t Wed Aug 13 05:09:33 2008
@@ -8,8 +8,10 @@
my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
- regex => qr/foo/,
- block => sub { push @calls, [@_] },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/foo/,
+ block => sub { push @calls, [@_] },
+ ),
);
$dispatcher->run('foo', 42);
Modified: Path-Dispatcher/trunk/t/010-return.t
==============================================================================
--- Path-Dispatcher/trunk/t/010-return.t (original)
+++ Path-Dispatcher/trunk/t/010-return.t Wed Aug 13 05:09:33 2008
@@ -8,8 +8,10 @@
my $dispatcher = Path::Dispatcher->new;
$dispatcher->add_rule(
- regex => qr/foo/,
- block => sub { return @_ },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/foo/,
+ block => sub { return @_ },
+ ),
);
is_deeply([$dispatcher->run('foo', 42)], []);
@@ -23,9 +25,11 @@
? $stage
: "${substage}_$stage";
$dispatcher->add_rule(
- stage => $qualified_stage,
- regex => qr/foo/,
- block => sub { return @_ },
+ Path::Dispatcher::Rule::Regex->new(
+ stage => $qualified_stage,
+ regex => qr/foo/,
+ block => sub { return @_ },
+ ),
);
}
}
Modified: Path-Dispatcher/trunk/t/101-subclass.t
==============================================================================
--- Path-Dispatcher/trunk/t/101-subclass.t (original)
+++ Path-Dispatcher/trunk/t/101-subclass.t Wed Aug 13 05:09:33 2008
@@ -24,10 +24,12 @@
]);
Path::Dispatcher::Test::App->dispatcher->add_rule(
- regex => qr/foo/,
- block => sub {
- push @calls, 'app on foo';
- },
+ Path::Dispatcher::Rule::Regex->new(
+ regex => qr/foo/,
+ block => sub {
+ push @calls, 'app on foo';
+ },
+ ),
);
Path::Dispatcher::Test::App->run('foo');
More information about the Bps-public-commit
mailing list