Permalink
Browse files

TODO test for empty string run mode

  • Loading branch information...
1 parent 5c883b8 commit fff40d0373324155e86877d989ad5d46f2b07c42 @moritz committed Jun 27, 2010
Showing with 17 additions and 4 deletions.
  1. +7 −3 lib/CGI/Application.pm
  2. +10 −1 t/basic.t
@@ -24,6 +24,7 @@ has %.callbacks = (
# the CGI object or hash
has %.query is rw;
+
multi method run() {
my $rm = $.__get_runmode($.mode-param);
$.current-runmode = $rm;
@@ -67,12 +68,15 @@ multi method call-hook($hook, *@args, *%opts) {
}
multi method __get_runmode($rm-param) {
+# warn "In __get_runmode\n";
my $rm = do given $rm-param {
- when Callable { .(self) }
- when Hash { .<run-mode> }
- default { $.query{$_} }
+ when Callable { .(self) }
+ when Associative { .<run-mode> }
+ default { %.query{$_} }
}
+# warn "Run mode (before): $rm.perl()";
$rm = $.start-mode unless defined($rm) && $rm.chars;
+# warn "Run mode (after): $rm.perl()";
return $rm;
}
View
@@ -14,11 +14,13 @@ BEGIN { @*INC.push('t/lib', 'lib') };
use CGI::Application;
-sub response-like($app, Mu $header, Mu $body, $comment, :$todo-header) {
+sub response-like($app, Mu $header, Mu $body, $comment,
+ :$todo-header, :$todo-body) {
my $output = $app.run;
my @hb = $output.split(rx{\r?\n\r?\n});
todo($todo-header) if $todo-header;
ok ?(@hb[0] ~~ $header), "$comment (header)" or diag "Got: @hb[0].perl()";
+ todo($todo-body) if $todo-body;
ok ?(@hb[1] ~~ $body), "$comment (body)" or diag "Got: @hb[1].perl()";
}
@@ -168,6 +170,13 @@ if 0 {
rx{'Hello World: zero_mode OK'},
'0 as run mode',
);
+ response-like(
+ CallbackRunMode.new(query => {go_to_mode => ''}),
+ rx{^'Content-Type: text/html'},
+ rx{'Hello World: default_mode OK'},
+ :todo-body('empty string run mode fallback'),
+ 'empty string as run mode triggers fallback to start_mode',
+ );
}

0 comments on commit fff40d0

Please sign in to comment.