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

sartak at bestpractical.com sartak at bestpractical.com
Wed Jul 30 16:26:42 EDT 2008


Author: sartak
Date: Wed Jul 30 16:26:34 2008
New Revision: 14671

Added:
   Path-Dispatcher/trunk/t/008-super-dispatcher.t
Modified:
   Path-Dispatcher/trunk/   (props changed)

Log:
 r68108 at onn:  sartak | 2008-07-30 16:26:22 -0400
 Add failing tests for having a super dispatcher


Added: Path-Dispatcher/trunk/t/008-super-dispatcher.t
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/t/008-super-dispatcher.t	Wed Jul 30 16:26:34 2008
@@ -0,0 +1,58 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+use Path::Dispatcher;
+
+my @calls;
+
+my $super_dispatcher = Path::Dispatcher->new;
+my $sub_dispatcher   = Path::Dispatcher->new(
+    super_dispatcher => $super_dispatcher,
+);
+
+for my $stage (qw/before on after/) {
+    $super_dispatcher->add_rule(
+        stage => $stage,
+        regex => qr/foo/,
+        block => sub { push @calls, "super $stage" },
+    );
+}
+
+for my $stage (qw/before after/) {
+    $sub_dispatcher->add_rule(
+        stage => $stage,
+        regex => qr/foo/,
+        block => sub { push @calls, "sub $stage" },
+    );
+}
+
+$super_dispatcher->run('foo');
+is_deeply([splice @calls], [
+    'super before',
+    'super on',
+    'super after',
+]);
+
+$sub_dispatcher->run('foo');
+is_deeply([splice @calls], [
+    'sub before',
+    'super before',
+    'super on',
+    'super after',
+    'sub after',
+]);
+
+$sub_dispatcher->add_rule(
+    stage => 'on',
+    regex => qr/foo/,
+    block => sub { push @calls, "sub on" },
+);
+
+$sub_dispatcher->run('foo');
+is_deeply([splice @calls], [
+    'sub before',
+    'sub on',
+    'sub after',
+]);
+



More information about the Bps-public-commit mailing list