[Bps-public-commit] Path-Dispatcher branch, master, updated. f53ef41293dbcd0eddcba3794869a19701cf0f04
sartak at bestpractical.com
sartak at bestpractical.com
Tue Mar 16 08:27:38 EDT 2010
The branch, master has been updated
via f53ef41293dbcd0eddcba3794869a19701cf0f04 (commit)
from a9dd88655f4aa8e7582e184b0cceca391ffe386e (commit)
Summary of changes:
t/025-sequence-custom-rule.t | 70 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit f53ef41293dbcd0eddcba3794869a19701cf0f04
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Mar 16 08:27:32 2010 -0400
More completion tests
diff --git a/t/025-sequence-custom-rule.t b/t/025-sequence-custom-rule.t
index 20a1ca7..cf1f726 100644
--- a/t/025-sequence-custom-rule.t
+++ b/t/025-sequence-custom-rule.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 15;
+use Test::More tests => 47;
use Path::Dispatcher;
my @calls;
@@ -54,3 +54,71 @@ is_deeply([$dispatcher->complete("use py")], ["use python"]);
is_deeply([$dispatcher->complete("use px")], []);
is_deeply([$dispatcher->complete("use x")], []);
+
+$dispatcher = Path::Dispatcher->new(
+ rules => [
+ Path::Dispatcher::Rule::Sequence->new(
+ rules => [
+ Path::Dispatcher::Rule::Eq->new(string => 'use'),
+ MyApp::Dispatcher::Rule::Language->new,
+ Path::Dispatcher::Rule::Eq->new(string => 'please'),
+ ],
+ block => sub { push @calls, [$1, $2, $3, $4] },
+ ),
+ ],
+);
+
+$dispatcher->run("use perl");
+is_deeply([splice @calls], []);
+
+$dispatcher->run("use perl please");
+is_deeply([splice @calls], [["use", "perl", "please", undef]]);
+
+$dispatcher->run("use python");
+is_deeply([splice @calls], []);
+
+$dispatcher->run("use python please");
+is_deeply([splice @calls], [["use", "python", "please", undef]]);
+
+$dispatcher->run("use php");
+is_deeply([splice @calls], []);
+
+$dispatcher->run("use php please");
+is_deeply([splice @calls], [["use", "php", "please", undef]]);
+
+$dispatcher->run("use ruby");
+is_deeply([splice @calls], []);
+
+$dispatcher->run("use ruby please");
+is_deeply([splice @calls], [["use", "ruby", "please", undef]]);
+
+$dispatcher->run("use c++");
+is_deeply([splice @calls], []);
+
+$dispatcher->run("use c++ please");
+is_deeply([splice @calls], []);
+
+is_deeply([$dispatcher->complete("u")], ["use"]);
+is_deeply([$dispatcher->complete("use")], ["use ruby", "use perl", "use php", "use python"]);
+is_deeply([$dispatcher->complete("use ")], ["use ruby", "use perl", "use php", "use python"]);
+is_deeply([$dispatcher->complete("use r")], ["use ruby"]);
+is_deeply([$dispatcher->complete("use p")], ["use perl", "use php", "use python"]);
+is_deeply([$dispatcher->complete("use pe")], ["use perl"]);
+is_deeply([$dispatcher->complete("use ph")], ["use php"]);
+is_deeply([$dispatcher->complete("use py")], ["use python"]);
+is_deeply([$dispatcher->complete("use px")], []);
+is_deeply([$dispatcher->complete("use x")], []);
+
+is_deeply([$dispatcher->complete("use ruby")], ["use ruby please"]);
+is_deeply([$dispatcher->complete("use ruby ")], ["use ruby please"]);
+is_deeply([$dispatcher->complete("use ruby pl")], ["use ruby please"]);
+is_deeply([$dispatcher->complete("use ruby pleas")], ["use ruby please"]);
+is_deeply([$dispatcher->complete("use ruby please")], []);
+is_deeply([$dispatcher->complete("use ruby plx")], []);
+
+is_deeply([$dispatcher->complete("use perl")], ["use perl please"]);
+is_deeply([$dispatcher->complete("use perl ")], ["use perl please"]);
+is_deeply([$dispatcher->complete("use perl pl")], ["use perl please"]);
+is_deeply([$dispatcher->complete("use perl pleas")], ["use perl please"]);
+is_deeply([$dispatcher->complete("use perl please")], []);
+is_deeply([$dispatcher->complete("use perl plx")], []);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list