[Bps-public-commit] Path-Dispatcher branch, complete, created. 897c175070e0ec4ef966cf8746035c04d66c452c

sartak at bestpractical.com sartak at bestpractical.com
Fri Dec 18 17:39:59 EST 2009


The branch, complete has been created
        at  897c175070e0ec4ef966cf8746035c04d66c452c (commit)

- Log -----------------------------------------------------------------
commit 897c175070e0ec4ef966cf8746035c04d66c452c
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Dec 18 17:39:37 2009 -0500

    Basic tests for completion

diff --git a/t/300-complete-simple.t b/t/300-complete-simple.t
new file mode 100644
index 0000000..50ef538
--- /dev/null
+++ b/t/300-complete-simple.t
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 6;
+
+do {
+    package MyApp::Dispatcher;
+    use Path::Dispatcher::Declarative -base;
+
+    on qr/(b)(ar)(.*)/ => sub { die "do not call blocks!" };
+    on ['token', 'matching'] => sub { die "do not call blocks!" };
+
+    rewrite quux => 'bar';
+    rewrite qr/^quux-(.*)/ => sub { "bar:$1" };
+
+    on alpha => sub { die "do not call blocks!" };
+
+    under alpha => sub {
+        then { die "do not call blocks!" };
+        on one => sub { die "do not call blocks!" };
+        then { die "do not call blocks!" };
+        on two => sub { die "do not call blocks!" };
+        on three => sub { die "do not call blocks!" };
+    };
+};
+
+my $dispatcher = MyApp::Dispatcher->dispatcher;
+is_deeply([$dispatcher->complete('x')], [], 'no completions for "x"');
+is_deeply([$dispatcher->complete('a')], ['alpha'], 'one completion for "a"');
+is_deeply([$dispatcher->complete('alpha')], ['one', 'two', 'three'], 'three completions for "alpha"');
+is_deeply([$dispatcher->complete('q')], ['quux'], 'one completion for "quux"');
+
+TODO: {
+    local $TODO = "cannot complete regex rules (yet!)";
+    is_deeply([$dispatcher->complete('quux')], ['quux-'], 'one completion for "quux"');
+    is_deeply([$dispatcher->complete('b')], ['bar'], 'one completion for "bar"');
+};
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list