Permalink
Browse files

Initial CGI::Application stub

  • Loading branch information...
0 parents commit 7c2e797a8631b00f60cdecb781a9c32a5bc1d097 @moritz committed Jun 26, 2010
Showing with 43 additions and 0 deletions.
  1. +11 −0 lib/CGI/Application.pm
  2. +32 −0 t/basic.t
@@ -0,0 +1,11 @@
+class CGI::Application;
+
+has %.run-modes is rw;
+has $.start-mode is rw = 'start';
+has %.mode-param is rw;
+
+has %.query is rw;
+
+multi method run() { "HEADER\r\n\r\nBODY" }
+
+# vim: ft=perl6
@@ -0,0 +1,32 @@
+use v6;
+use Test;
+
+plan *;
+
+#%*ENV<CGI_APP_RETURN_ONLY> = 1;
+
+BEGIN { @*INC.push('t/lib', 'lib') };
+
+use CGI::Application;
+
+
+sub response-like($app, Mu $header, Mu $body, $comment) {
+ my $output = $app.run;
+ my ($h, $b) = $output.split("\r\n\r\n");
+ ok ?($h ~~ $header), "$comment (header)";
+ ok ?($b ~~ $body), "$comment (body)";
+}
+
+{
+ my $app = CGI::Application.new;
+ isa_ok $app, CGI::Application;
+ # TODO: make that CGI.new
+ $app.query = {};
+ response-like($app,
+ rx{^ 'Content-Type: text/html'},
+ rx{ 'Query Environment' },
+ 'base class response',
+ );
+}
+
+done_testing;

0 comments on commit 7c2e797

Please sign in to comment.