Update CPANPLUS::Dist::Build to CPAN version 0.32
[p5sagit/p5-mst-13.2.git] / lib / perl5db.t
CommitLineData
635f2c9e 1#!/usr/bin/perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
9use strict;
10use warnings;
11
12BEGIN {
13 if (!-c "/dev/null") {
14 print "1..0 # Skip: no /dev/null\n";
15 exit 0;
16 }
98274836 17my $dev_tty = '/dev/tty';
18 $dev_tty = 'TT:' if ($^O eq 'VMS');
19 if (!-c $dev_tty) {
20 print "1..0 # Skip: no $dev_tty\n";
9366364f 21 exit 0;
22 }
b091e0d1 23 if ($ENV{PERL5DB}) {
24 print "1..0 # Skip: \$ENV{PERL5DB} is already set to '$ENV{PERL5DB}'\n";
25 exit 0;
26 }
635f2c9e 27}
28
6fd69bbe 29plan(2);
635f2c9e 30
31sub rc {
32 open RC, ">", ".perldb" or die $!;
33 print RC @_;
34 close(RC);
3e5e55bd 35 # overly permissive perms gives "Must not source insecure rcfile"
36 # and hangs at the DB(1> prompt
37 chmod 0644, ".perldb";
635f2c9e 38}
39
cd4eab35 40my $target = '../lib/perl5db/t/eval-line-bug';
41
635f2c9e 42rc(
43 qq|
cd4eab35 44 &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
635f2c9e 45 \n|,
46
47 qq|
48 sub afterinit {
49 push(\@DB::typeahead,
635f2c9e 50 'b 23',
cd4eab35 51 'n',
52 'n',
53 'n',
54 'c', # line 23
55 'n',
56 "p \\\@{'main::_<$target'}",
635f2c9e 57 'q',
58 );
59 }\n|,
60);
61
c18cf8ce 62{
63 local $ENV{PERLDB_OPTS} = "ReadLine=0";
64 runperl(switches => [ '-d' ], progfile => $target);
65}
635f2c9e 66
67my $contents;
68{
69 local $/;
70 open I, "<", 'db.out' or die $!;
71 $contents = <I>;
72 close(I);
73}
74
cd4eab35 75like($contents, qr/sub factorial/,
635f2c9e 76 'The ${main::_<filename} variable in the debugger was not destroyed'
77);
78
1ad62f64 79{
6fd69bbe 80 local $ENV{PERLDB_OPTS} = "ReadLine=0";
6fd69bbe 81 my $output = runperl(switches => [ '-d' ], progfile => '../lib/perl5db/t/lvalue-bug');
82 like($output, qr/foo is defined/, 'lvalue subs work in the debugger');
83}
84
635f2c9e 85# clean up.
86
87END {
7cd48731 88 1 while unlink qw(.perldb db.out);
635f2c9e 89}