[Bps-public-commit] Path-Dispatcher branch, complete, updated. 301d1354d9b8468a7861c203dcf2973ef154faff

sartak at bestpractical.com sartak at bestpractical.com
Fri Dec 18 19:25:01 EST 2009


The branch, complete has been updated
       via  301d1354d9b8468a7861c203dcf2973ef154faff (commit)
       via  8bc5f7478a49c19528c1eb9fdcd9fdfb02723546 (commit)
      from  fd41e0f526652b4ab562959a10aaefb6d63137bd (commit)

Summary of changes:
 lib/Path/Dispatcher/Rule/Under.pm |    2 +-
 t/301-complete-complex.t          |   52 +++++++++++++++++++++++-------------
 2 files changed, 34 insertions(+), 20 deletions(-)

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

    Handle delimiters infinitesimally better

diff --git a/lib/Path/Dispatcher/Rule/Under.pm b/lib/Path/Dispatcher/Rule/Under.pm
index f0350bf..4b270d1 100644
--- a/lib/Path/Dispatcher/Rule/Under.pm
+++ b/lib/Path/Dispatcher/Rule/Under.pm
@@ -50,7 +50,7 @@ sub complete {
 
     my $prefix = substr($path->path, 0, length($path->path) - length($new_path->path));
 
-    return map { "$prefix$_" } map { $_->complete($new_path) } $self->rules;
+    return map { "$prefix $_" } map { $_->complete($new_path) } $self->rules;
 }
 
 sub readable_attributes { shift->predicate->readable_attributes }

commit 301d1354d9b8468a7861c203dcf2973ef154faff
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Dec 18 19:24:51 2009 -0500

    Refactor tests to use new complete_ok

diff --git a/t/301-complete-complex.t b/t/301-complete-complex.t
index 883371a..f57b02e 100644
--- a/t/301-complete-complex.t
+++ b/t/301-complete-complex.t
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 17;
+use Test::More tests => 16;
 
 do {
     package MyApp::Dispatcher;
@@ -30,30 +30,44 @@ do {
 };
 
 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')], ['alpha one', 'alpha two', 'alpha three'], 'three completions for "alpha"');
+sub complete_ok {
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+    my $path     = shift;
+    my @expected = @_;
 
-is_deeply([$dispatcher->complete('t')], ['token'], 'one completion for "t"');
-is_deeply([$dispatcher->complete('token')], ['token matching'], 'one completion for "token"');
-is_deeply([$dispatcher->complete('token ')], ['token matching'], 'one completion for "token "');
-is_deeply([$dispatcher->complete('token m')], ['token matching'], 'one completion for "token m"');
-is_deeply([$dispatcher->complete('token matchin')], ['token matching'], 'one completion for "token matchin"');
-is_deeply([$dispatcher->complete('token matching')], [], 'no completions for "token matching"');
+    my @got = $dispatcher->complete($path);
 
-is_deeply([$dispatcher->complete('q')], ['quux'], 'one completion for "quux"');
+    my $message = @expected == 0 ? "no completions"
+                : @expected == 1 ? "one completion"
+                :                  @expected . " completions";
+    $message .= " for path '$path'";
 
-is_deeply([$dispatcher->complete('bet')], ['beta'], 'one completion for "beta"');
-is_deeply([$dispatcher->complete('beta')], ['beta a', 'beta b'], 'two completions for "beta"');
-is_deeply([$dispatcher->complete('beta ')], ['beta a', 'beta b'], 'two completions for "beta "');
-is_deeply([$dispatcher->complete('beta a')], [], 'no completions for "beta a"');
-is_deeply([$dispatcher->complete('beta b')], [], 'no completions for "beta b"');
-is_deeply([$dispatcher->complete('beta c')], [], 'no completions for "beta c"');
+    is_deeply(\@got, \@expected, $message);
+}
+
+complete_ok('x');
+
+complete_ok(q => 'quux');
+
+complete_ok(a => 'alpha');
+complete_ok(alpha => 'alpha one', 'alpha two', 'alpha three');
+
+complete_ok(t => 'token');
+complete_ok(token => 'token matching');
+complete_ok('token m' => 'token matching');
+complete_ok('token matchin' => 'token matching');
+complete_ok('token matching');
+
+complete_ok(bet => 'beta');
+complete_ok(beta => 'beta a', 'beta b');
+complete_ok('beta a');
+complete_ok('beta b');
+complete_ok('beta c');
 
 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"');
+    complete_ok(quux => 'quux-');
+    complete_ok(b => 'bar', 'beta');
 };
 

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



More information about the Bps-public-commit mailing list