+# perl 5 RT #121509 regression bug.
+# “perl debugger doesn't save starting dir to restart from”
+# Thanks to Linda Walsh for reporting it.
+{
+ use File::Temp qw/tempdir/;
+
+ my $temp_dir = tempdir( CLEANUP => 1 );
+
+ local $ENV{__PERLDB_TEMP_DIR} = $temp_dir;
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ # This is to avoid getting the "Debugger program terminated"
+ # junk that interferes with the normal output.
+ 'b _after_chdir',
+ 'c',
+ 'R',
+ 'b _finale',
+ 'c',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'n',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/rt-121509-restart-after-chdir',
+ }
+ );
+
+ $wrapper->output_like(
+ qr/
+In\ _finale\ No\ 1
+ .*?
+In\ _finale\ No\ 2
+ .*?
+In\ _finale\ No\ 3
+ /msx,
+ "Test that the debugger chdirs to the initial directory after a restart.",
+ );
+}
+# Test the perldoc command
+# We don't actually run the program, but we need to provide one to the wrapper.
+SKIP:
+{
+ $^O eq "linux"
+ or skip "man errors aren't especially portable", 1;
+ -x '/usr/bin/man'
+ or skip "man command seems to be missing", 1;
+ local $ENV{LANG} = "C";
+ local $ENV{LC_MESSAGES} = "C";
+ local $ENV{LC_ALL} = "C";
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ 'perldoc perlrules',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/fact',
+ }
+ );
+
+ $wrapper->output_like(
+ qr/No (?:manual )?entry for perlrules/,
+ 'perldoc command works fine',
+ );
+}
+
+# [perl #71678] debugger bug in evaluation of user actions ('a' command)
+# Still evaluated after the script finishes.
+{
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ q#a 9 print " \$arg = $arg\n"#,
+ 'c 9',
+ 's',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/test-a-statement-2',
+ switches => [ '-dw', ],
+ stderr => 1,
+ }
+ );
+
+ $wrapper->contents_unlike(qr/
+ Use\ of\ uninitialized\ value\ \$arg\ in\ concatenation\ [\S ]+\ or\ string\ at
+ /msx,
+ 'Test that the a command does not emit warnings on program exit.',
+ );
+}
+
+{
+ # perl 5 RT #126735 regression bug.
+ local $ENV{PERLDB_OPTS} = "NonStop=0 RemotePort=non-existent-host.tld:9001";
+ my $output = runperl( stdin => "q\n", stderr => 1, switches => [ '-d' ], prog => '../lib/perl5db/t/fact' );
+ like(
+ $output,
+ qr/^Unable to connect to remote host:/ms,
+ 'Tried to connect.',
+ );
+ unlike(
+ $output,
+ qr/syntax error/,
+ 'Can quit from the debugger after a wrong RemotePort',
+ );
+}
+
+{
+ # perl 5 RT #120174 - 'p' command
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ 'b 2',
+ 'c',
+ 'p@abc',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/rt-120174',
+ }
+ );
+
+ $wrapper->contents_like(
+ qr/1234/,
+ q/RT 120174: p command can be invoked without space after 'p'/,
+ );
+}
+
+{
+ # perl 5 RT #120174 - 'x' command on array
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ 'b 2',
+ 'c',
+ 'x@abc',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/rt-120174',
+ }
+ );
+
+ $wrapper->contents_like(
+ qr/0\s+1\n1\s+2\n2\s+3\n3\s+4/ms,
+ q/RT 120174: x command can be invoked without space after 'x' before array/,
+ );
+}
+
+{
+ # perl 5 RT #120174 - 'x' command on array ref
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ 'b 2',
+ 'c',
+ 'x\@abc',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/rt-120174',
+ }
+ );
+
+ $wrapper->contents_like(
+ qr/\s+0\s+1\n\s+1\s+2\n\s+2\s+3\n\s+3\s+4/ms,
+ q/RT 120174: x command can be invoked without space after 'x' before array ref/,
+ );
+}
+
+{
+ # perl 5 RT #120174 - 'x' command on hash ref
+ my $wrapper = DebugWrap->new(
+ {
+ cmds =>
+ [
+ 'b 4',
+ 'c',
+ 'x\%xyz',
+ 'q',
+ ],
+ prog => '../lib/perl5db/t/rt-120174',
+ }
+ );
+
+ $wrapper->contents_like(
+ qr/\s+'alpha'\s+=>\s+'beta'\n\s+'gamma'\s+=>\s+'delta'/ms,
+ q/RT 120174: x command can be invoked without space after 'x' before hash ref/,
+ );
+}
+