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

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 29 17:16:51 EDT 2008


Author: sartak
Date: Tue Jul 29 17:16:51 2008
New Revision: 14627

Added:
   Path-Dispatcher/trunk/t/006-abort.t
Modified:
   Path-Dispatcher/trunk/   (props changed)

Log:
 r67921 at onn:  sartak | 2008-07-29 17:16:47 -0400
 (Failing) tests for aborting the dispatch


Added: Path-Dispatcher/trunk/t/006-abort.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/006-abort.t	Tue Jul 29 17:16:51 2008
@@ -0,0 +1,52 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 6;
+use Test::Exception;
+use Path::Dispatcher;
+
+my @calls;
+
+my $dispatcher = Path::Dispatcher->new;
+$dispatcher->add_rule(
+    regex => qr/foo/,
+    block => sub {
+        push @calls, "on";
+        die "Patch::Dispatcher abort\n";
+    },
+);
+
+$dispatcher->add_rule(
+    stage => 'after',
+    regex => qr/foo/,
+    block => sub {
+        push @calls, "after";
+    },
+);
+
+my $thunk;
+lives_ok {
+    $thunk = $dispatcher->dispatch('foo');
+};
+is_deeply([splice @calls], [], "no blocks called yet of course");
+
+lives_ok {
+    $thunk->();
+};
+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: after";
+    },
+);
+
+throws_ok {
+    $dispatcher->run('bar');
+} qr/Not a CODE reference/;
+
+is_deeply([splice @calls], ['bar: before'], "regular dies pass through");
+



More information about the Bps-public-commit mailing list