can(undef) on 5.8.x blows up, work around it
[catagits/Web-Simple.git] / t / dispatch_misc.t
index a4ab38a..0c27413 100644 (file)
@@ -17,6 +17,11 @@ my @dispatch;
     package MiscTest;
     sub dispatch_request { @dispatch }
     sub string_method { [ 999, [], [""] ]; }
+
+    sub can {
+        die "Passed undef to can, this blows up on 5.8" unless defined($_[1]);
+        shift->SUPER::can(@_)
+    }
 }
 
 my $app = MiscTest->new;
@@ -33,6 +38,7 @@ middleware_as_only_route();
 route_returns_middleware_plus_extra();
 route_returns_undef();
 matcher_nonsub_pair();
+matcher_undef_method();
 
 done_testing();
 
@@ -202,3 +208,13 @@ sub matcher_nonsub_pair {
     like $get->content, qr[No idea how we got here with Web::Dispatch::M],
       "the error message points out the broken definition";
 }
+
+sub matcher_undef_method {
+    @dispatch = ( 'GET', undef );
+
+    my $get = run_request( GET => 'http://localhost/' );
+
+    cmp_ok $get->code, '==', 500, "a route definition that pairs a WD::Matcher a non-sub dies";
+    like $get->content, qr[No idea how we got here with GET],
+      "the error message points out the broken definition";
+}