[Bps-public-commit] Path-Dispatcher branch, complete, updated. 8fe3edd918ea18f494d380af3432aa04997ddb1d

sartak at bestpractical.com sartak at bestpractical.com
Fri Dec 18 19:31:24 EST 2009


The branch, complete has been updated
       via  8fe3edd918ea18f494d380af3432aa04997ddb1d (commit)
      from  e0d23b3939e3ae6d47ce3437e1ada7d690db41b0 (commit)

Summary of changes:
 t/302-complete-delimiter.t |   57 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 t/302-complete-delimiter.t

- Log -----------------------------------------------------------------
commit 8fe3edd918ea18f494d380af3432aa04997ddb1d
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Dec 18 19:31:09 2009 -0500

    Painful delimiter tests

diff --git a/t/302-complete-delimiter.t b/t/302-complete-delimiter.t
new file mode 100644
index 0000000..3f9f46a
--- /dev/null
+++ b/t/302-complete-delimiter.t
@@ -0,0 +1,57 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 18;
+
+do {
+    package MyApp::Dispatcher;
+    use Path::Dispatcher::Declarative -base, -default => {
+        token_delimiter => '/',
+    };
+
+    on ['token', 'matching'] => sub { die "do not call blocks!" };
+
+    under alpha => sub {
+        on one => sub { 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;
+
+sub complete_ok {
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+    my $path     = shift;
+    my @expected = @_;
+
+    my @got = $dispatcher->complete($path);
+
+    my $message = @expected == 0 ? "no completions"
+                : @expected == 1 ? "one completion"
+                :                  @expected . " completions";
+    $message .= " for path '$path'";
+
+    is_deeply(\@got, \@expected, $message);
+}
+
+complete_ok(t => 'token');
+complete_ok(toke => 'token');
+complete_ok('token' => 'token/matching');
+complete_ok('token/' => 'token/matching');
+complete_ok('token/m' => 'token/matching');
+complete_ok('token/matchin' => 'token/matching');
+complete_ok('token/matching');
+complete_ok('token/x');
+complete_ok('token/mx');
+
+complete_ok(a => 'alpha');
+complete_ok(alph => 'alpha');
+complete_ok(alpha => 'alpha/one', 'alpha/two', 'alpha/three');
+complete_ok('alpha/' => 'alpha/one', 'alpha/two', 'alpha/three');
+complete_ok('alpha/o' => 'alpha/one');
+complete_ok('alpha/t' => 'alpha/two', 'alpha/three');
+complete_ok('alpha/tw' => 'alpha/two');
+complete_ok('alpha/th' => 'alpha/three');
+complete_ok('alpha/x');
+

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



More information about the Bps-public-commit mailing list