The following Perl gives Test::More 0.60 and 0.62 heartache:

$ perl -MTest::More=tests,1 -we'can_ok(undef,undef)'
1..1
Use of uninitialized value in concatenation (.) or string at 
.../5.8.6/Test/More.pm line 501.
Use of uninitialized value in concatenation (.) or string at 
.../5.8.6/Test/More.pm line 501.
not ok 1 - ->can('')
#     Failed test (-e at line 1)
Use of uninitialized value in concatenation (.) or string at 
.../5.8.6/Test/More.pm line 506.
Use of uninitialized value in concatenation (.) or string at 
.../5.8.6/Test/More.pm line 506.
#     ->can('') failed
# Looks like you failed 1 test of 1.
$

The following patch makes Test::More verify the class isn't false first.

==========================================================================
diff -ur Test-Simple-0.62/lib/Test/More.pm 
Test-Simple-0.62-patched/lib/Test/More.pm
--- Test-Simple-0.62/lib/Test/More.pm   2005-10-08 01:56:17.000000000 -0500
+++ Test-Simple-0.62-patched/lib/Test/More.pm   2005-11-09 09:22:44.000000000 
-0600
@@ -465,6 +465,12 @@
     my $class = ref $proto || $proto;
     my $tb = Test::More->builder;
 
+    unless( $class ) {
+        my $ok = $tb->ok( 0, "->can(...)" );
+        $tb->diag('    can_ok() called with empty class or reference');
+        return $ok;
+    }
+
     unless( @methods ) {
         my $ok = $tb->ok( 0, "$class->can(...)" );
         $tb->diag('    can_ok() called with no methods');
==========================================================================

The patch does not address a method name that is undefined.

-Pete K
-- 
Pete Krawczyk
  perl at bsod dot net


Reply via email to