[Bps-public-commit] r15453 - in Path-Dispatcher/trunk: lib/Path/Dispatcher t t/lib/Path/Dispatcher/Test
sartak at bestpractical.com
sartak at bestpractical.com
Mon Aug 25 19:47:00 EDT 2008
Author: sartak
Date: Mon Aug 25 19:46:59 2008
New Revision: 15453
Added:
Path-Dispatcher/trunk/t/102-abort.t
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm
Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm
Log:
r70335 at onn: sartak | 2008-08-25 19:46:47 -0400
Add sugar for next/last 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 Mon Aug 25 19:46:59 2008
@@ -81,6 +81,8 @@
),
);
},
+ next_rule => sub { die "Path::Dispatcher next rule\n" },
+ last_rule => sub { die "Path::Dispatcher abort\n" },
};
}
Added: Path-Dispatcher/trunk/t/102-abort.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/102-abort.t Mon Aug 25 19:46:59 2008
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 2;
+use lib 't/lib';
+use Path::Dispatcher::Test::App;
+
+our @calls;
+
+Path::Dispatcher::Test::App->run('abort');
+is_deeply([splice @calls], [
+ 'app before abort',
+]);
+
+Path::Dispatcher::Test::App->run('next rule');
+is_deeply([splice @calls], [
+ 'app before next_rule',
+ 'app before next_rule 2',
+ 'framework before next_rule',
+ 'framework before next_rule 2',
+]);
+
Modified: Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm
==============================================================================
--- Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm (original)
+++ Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/App.pm Mon Aug 25 19:46:59 2008
@@ -12,5 +12,23 @@
push @main::calls, 'app after foo';
};
+before qr/abort/ => sub {
+ push @main::calls, 'app before abort';
+ last_rule;
+ push @main::calls, 'app after abort';
+};
+
+on qr/next rule/ => sub {
+ push @main::calls, 'app before next_rule';
+ next_rule;
+ push @main::calls, 'app after next_rule';
+};
+
+on qr/next rule/ => sub {
+ push @main::calls, 'app before next_rule 2';
+ next_rule;
+ push @main::calls, 'app after next_rule 2';
+};
+
1;
Modified: Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm
==============================================================================
--- Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm (original)
+++ Path-Dispatcher/trunk/t/lib/Path/Dispatcher/Test/Framework.pm Mon Aug 25 19:46:59 2008
@@ -16,5 +16,21 @@
push @main::calls, 'framework after foo';
};
+on qr/abort/ => sub {
+ push @main::calls, 'framework on abort';
+};
+
+on qr/next rule/ => sub {
+ push @main::calls, 'framework before next_rule';
+ next_rule;
+ push @main::calls, 'framework after next_rule';
+};
+
+on qr/next rule/ => sub {
+ push @main::calls, 'framework before next_rule 2';
+ next_rule;
+ push @main::calls, 'framework after next_rule 2';
+};
+
1;
More information about the Bps-public-commit
mailing list