X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fperl5db.t;h=59acd7a059ca7e3fbeb53e19aad8dc2104914353;hb=6182169b72782336c6202161aa4cde16ac88296e;hp=9c95a5b84ca49f04c9d0d49051d9dd9ef7901034;hpb=cd4eab350f31b452f88e849e0c9d1309692f544f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/perl5db.t b/lib/perl5db.t index 9c95a5b..59acd7a 100644 --- a/lib/perl5db.t +++ b/lib/perl5db.t @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!./perl BEGIN { chdir 't' if -d 't'; @@ -8,15 +8,26 @@ BEGIN { use strict; use warnings; +use Config; BEGIN { if (!-c "/dev/null") { print "1..0 # Skip: no /dev/null\n"; exit 0; } +my $dev_tty = '/dev/tty'; + $dev_tty = 'TT:' if ($^O eq 'VMS'); + if (!-c $dev_tty) { + print "1..0 # Skip: no $dev_tty\n"; + exit 0; + } + if ($ENV{PERL5DB}) { + print "1..0 # Skip: \$ENV{PERL5DB} is already set to '$ENV{PERL5DB}'\n"; + exit 0; + } } -plan(1); +plan(8); sub rc { open RC, ">", ".perldb" or die $!; @@ -49,7 +60,10 @@ rc( }\n|, ); -runperl(switches => [ '-d' ], progfile => $target); +{ + local $ENV{PERLDB_OPTS} = "ReadLine=0"; + runperl(switches => [ '-d' ], progfile => $target); +} my $contents; { @@ -63,8 +77,99 @@ like($contents, qr/sub factorial/, 'The ${main::_ [ '-d' ], progfile => '../lib/perl5db/t/lvalue-bug'); + 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 = ; + close(I); + } + unlike($contents, qr/INCORRECT/, "[perl #61222]"); +} + + + +# Test for Proxy constants +{ + rc( + qq| + &parse_options("NonStop=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]"); +} + + # clean up. END { - unlink qw(.perldb db.out); + 1 while unlink qw(.perldb db.out); }