Fix (and test) module listing in the debugger
authorVincent Pit <perl@profvince.com>
Mon, 25 Jun 2012 13:49:06 +0000 (15:49 +0200)
committerVincent Pit <perl@profvince.com>
Mon, 25 Jun 2012 13:49:06 +0000 (15:49 +0200)
This was also broken when 'use strict' was added.

MANIFEST
lib/perl5db.pl
lib/perl5db.t
lib/perl5db/t/load-modules [new file with mode: 0644]

index 3fbacb5..203b4a6 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4282,6 +4282,7 @@ lib/perl5db/t/EnableModule.pm     Tests for the Perl debugger
 lib/perl5db/t/eval-line-bug    Tests for the Perl debugger
 lib/perl5db/t/fact             Tests for the Perl debugger
 lib/perl5db/t/filename-line-breakpoint         Tests for the Perl debugger
+lib/perl5db/t/load-modules     Tests for the Perl debugger
 lib/perl5db/t/lvalue-bug       Tests for the Perl debugger
 lib/perl5db/t/MyModule.pm      Tests for the Perl debugger
 lib/perl5db/t/proxy-constants  Tests for the Perl debugger
index b692f6f..6e08d59 100644 (file)
@@ -7202,8 +7202,9 @@ sub list_modules {    # versions
 
         # If the package has a $VERSION package global (as all good packages
         # should!) decode it and save as partial message.
-        if ( defined ${ $_ . '::VERSION' } ) {
-            $version{$file} = "${ $_ . '::VERSION' } from ";
+        my $pkg_version = do { no strict 'refs'; ${ $_ . '::VERSION' } };
+        if ( defined $pkg_version ) {
+            $version{$file} = "$pkg_version from ";
         }
 
         # Finish up the message with the file the package came from.
index 634288c..7cca75c 100644 (file)
@@ -28,7 +28,7 @@ BEGIN {
     }
 }
 
-plan(31);
+plan(32);
 
 my $rc_filename = '.perldb';
 
@@ -831,6 +831,25 @@ package main;
     );
 }
 
+# Test for 'M' (module list).
+{
+    my $wrapper = DebugWrap->new(
+        {
+            cmds =>
+            [
+                'M',
+                'q',
+            ],
+            prog => '../lib/perl5db/t/load-modules'
+        }
+    );
+
+    $wrapper->contents_like(
+        qr[Scalar/Util\.pm],
+        'M (module list) works fine',
+    );
+}
+
 END {
     1 while unlink ($rc_filename, $out_fn);
 }
diff --git a/lib/perl5db/t/load-modules b/lib/perl5db/t/load-modules
new file mode 100644 (file)
index 0000000..2023263
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Scalar::Util;