This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In Perl_fbm_instr(), no need to calculate the address of the table if
[perl5.git] / lib / perl5db.t
1 #!/usr/bin/perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7 }
8
9 use strict;
10 use warnings;
11
12 BEGIN {
13     if (!-c "/dev/null") {
14         print "1..0 # Skip: no /dev/null\n";
15         exit 0;
16     }
17 }
18
19 plan(1);
20
21 sub rc {
22     open RC, ">", ".perldb" or die $!;
23     print RC @_;
24     close(RC);
25     # overly permissive perms gives "Must not source insecure rcfile"
26     # and hangs at the DB(1> prompt
27     chmod 0644, ".perldb";
28 }
29
30 my $target = '../lib/perl5db/t/eval-line-bug';
31
32 rc(
33     qq|
34     &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
35     \n|,
36
37     qq|
38     sub afterinit {
39         push(\@DB::typeahead,
40             'b 23',
41             'n',
42             'n',
43             'n',
44             'c', # line 23
45             'n',
46             "p \\\@{'main::_<$target'}",
47             'q',
48         );
49     }\n|,
50 );
51
52 runperl(switches => [ '-d' ], progfile => $target);
53
54 my $contents;
55 {
56     local $/;
57     open I, "<", 'db.out' or die $!;
58     $contents = <I>;
59     close(I);
60 }
61
62 like($contents, qr/sub factorial/,
63     'The ${main::_<filename} variable in the debugger was not destroyed'
64 );
65
66 # clean up.
67
68 END {
69     unlink qw(.perldb db.out);
70 }