[Bps-public-commit] r14814 - in Path-Dispatcher/trunk: lib/Path t

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 5 18:52:40 EDT 2008


Author: sartak
Date: Tue Aug  5 18:52:40 2008
New Revision: 14814

Added:
   Path-Dispatcher/trunk/t/010-return.t
Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/lib/Path/Dispatcher.pm

Log:
 r54129 at gorgoroth:  sartak | 2008-08-05 18:52:37 -0400
 Make sure that we return no useful value, so we don't have to worry about backwards compatibility when we figure out how to return values from a dispatch/run


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	Tue Aug  5 18:52:40 2008
@@ -151,6 +151,8 @@
         };
 
         die $@ if $@ && $@ !~ /^Patch::Dispatcher abort\n/;
+
+        return;
     };
 }
 
@@ -174,7 +176,9 @@
     my $path = shift;
     my $code = $self->dispatch($path);
 
-    return $code->(@_);
+    $code->(@_);
+
+    return;
 }
 
 sub begin_stage {}

Added: Path-Dispatcher/trunk/t/010-return.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/010-return.t	Tue Aug  5 18:52:40 2008
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 4;
+use Path::Dispatcher;
+
+# we currently have no defined return strategy :/
+
+my $dispatcher = Path::Dispatcher->new;
+$dispatcher->add_rule(
+    regex => qr/foo/,
+    block => sub { return @_ },
+);
+
+is_deeply([$dispatcher->run('foo', 42)], []);
+
+my $code = $dispatcher->dispatch('foo');
+is_deeply([$code->(24)], []);
+
+for my $stage (qw/first on last/) {
+    for my $substage (qw/before on after/) {
+        my $qualified_stage = $substage eq 'on'
+                            ? $stage
+                            : "${substage}_$stage";
+        $dispatcher->add_rule(
+            stage => $qualified_stage,
+            regex => qr/foo/,
+            block => sub { return @_ },
+        );
+    }
+}
+
+is_deeply([$dispatcher->run('foo', 42)], []);
+
+$code = $dispatcher->dispatch('foo');
+is_deeply([$code->(24)], []);
+



More information about the Bps-public-commit mailing list