This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bump Carp.pm version since it now differs from 5.13.9
[perl5.git] / lib / perl5db.t
index 67b5fda..4419136 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!./perl
 
 BEGIN {
     chdir 't' if -d 't';
@@ -8,6 +8,7 @@ BEGIN {
 
 use strict;
 use warnings;
+use Config;
 
 BEGIN {
     if (!-c "/dev/null") {
@@ -26,7 +27,7 @@ my $dev_tty = '/dev/tty';
     }
 }
 
-plan(2);
+plan(9);
 
 sub rc {
     open RC, ">", ".perldb" or die $!;
@@ -82,6 +83,101 @@ like($contents, qr/sub factorial/,
     like($output, qr/foo is defined/, 'lvalue subs work in the debugger');
 }
 
+{
+    local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
+    my $output = runperl(switches => [ '-d' ], progfile => '../lib/perl5db/t/symbol-table-bug');
+    like($output, qr/Undefined symbols 0/, 'there are no undefined values in the symbol table');
+}
+
+SKIP: {
+    if ( $Config{usethreads} ) {
+        skip('This perl has threads, skipping non-threaded debugger tests');
+    } else {
+        my $error = 'This Perl not built to support threads';
+        my $output = runperl( switches => [ '-dt' ], stderr => 1 );
+        like($output, qr/$error/, 'Perl debugger correctly complains that it was not built with threads');
+    }
+
+}
+SKIP: {
+    if ( $Config{usethreads} ) {
+        local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
+        my $output = runperl(switches => [ '-dt' ], progfile => '../lib/perl5db/t/symbol-table-bug');
+        like($output, qr/Undefined symbols 0/, 'there are no undefined values in the symbol table when running with thread support');
+    } else {
+        skip("This perl is not threaded, skipping threaded debugger tests");
+    }
+}
+
+
+# Test [perl #61222]
+{
+    rc(
+        qq|
+        &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
+        \n|,
+
+        qq|
+        sub afterinit {
+            push(\@DB::typeahead,
+                'm Pie',
+                'q',
+            );
+        }\n|,
+    );
+
+    my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/rt-61222');
+    my $contents;
+    {
+        local $/;
+        open I, "<", 'db.out' or die $!;
+        $contents = <I>;
+        close(I);
+    }
+    unlike($contents, qr/INCORRECT/, "[perl #61222]");
+}
+
+
+
+# Test for Proxy constants
+{
+    rc(
+        qq|
+        &parse_options("NonStop=0 ReadLine=0 TTY=db.out LineInfo=db.out");
+        \n|,
+
+        qq|
+        sub afterinit {
+            push(\@DB::typeahead,
+                'm main->s1',
+                'q',
+            );
+        }\n|,
+    );
+
+    my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/proxy-constants');
+    is($output, "", "proxy constant subroutines");
+}
+
+
+# [perl #66110] Call a subroutine inside a regex
+{
+    local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
+    my $output = runperl(switches => [ '-d' ], stderr => 1, progfile => '../lib/perl5db/t/rt-66110');
+    like($output, "All tests successful.", "[perl #66110]");
+}
+
+# taint tests
+
+{
+    local $ENV{PERLDB_OPTS} = "ReadLine=0 NonStop=1";
+    my $output = runperl(switches => [ '-d', '-T' ], stderr => 1,
+                       progfile => '../lib/perl5db/t/taint');
+    chomp $output if $^O eq 'VMS'; # newline guaranteed at EOF
+    is($output, '[$^X][done]', "taint");
+}
+
+
 # clean up.
 
 END {