fix a memory leak introduced by 1f8cad5e5a1875de94d63ac91d8ded4d2282c62e
[catagits/Web-Simple.git] / t / dispatch_misc.t
index 517a3e0..842cf52 100644 (file)
@@ -16,11 +16,13 @@ my @dispatch;
 
     package MiscTest;
     sub dispatch_request { @dispatch }
+    sub string_method { [ 999, [], [""] ]; }
 }
 
 my $app = MiscTest->new;
 sub run_request { $app->run_test_request( @_ ); }
 
+string_method_name();
 app_is_non_plack();
 app_is_object();
 app_is_just_sub();
@@ -34,6 +36,14 @@ matcher_nonsub_pair();
 
 done_testing();
 
+sub string_method_name {
+    @dispatch = ( '/' => "string_method" );
+
+    my $get = run_request( GET => 'http://localhost/' );
+
+    cmp_ok $get->code, '==', 999, "a dispatcher that's a string matching a method on the dispatch object gets executed";
+}
+
 sub app_is_non_plack {
 
     my $r = HTTP::Response->new( 999 );
@@ -54,7 +64,8 @@ sub app_is_object {
         sub to_app { [ 999, [], ["ok"] ] }
     }
 
-    my $d = Web::Dispatch->new( dispatch_object => ObjectApp->new );
+    my $o = ObjectApp->new;
+    my $d = Web::Dispatch->new( dispatch_object => $o );
     my $res = $d->call;
 
     cmp_ok $res->[0], '==', 999, "Web::Dispatch can dispatch properly, given only an object with to_app method";