This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
test and briefly document DB::goto
authorTony Cook <tony@develop-help.com>
Tue, 10 Sep 2013 06:39:13 +0000 (16:39 +1000)
committerTony Cook <tony@develop-help.com>
Mon, 16 Sep 2013 04:49:42 +0000 (14:49 +1000)
MANIFEST
pod/perldebguts.pod
t/lib/Devel/switchd_goto.pm [new file with mode: 0644]
t/run/switchd.t

index 895d263..c040aa2 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5034,6 +5034,7 @@ t/lib/deprecate/Optionally.pm     Optionally deprecated module to test deprecate.pm
 t/lib/deprecate.t              Test deprecate.pm
 t/lib/Devel/nodb.pm            Module for t/run/switchd.t
 t/lib/Devel/switchd_empty.pm   Module for t/run/switchd.t
+t/lib/Devel/switchd_goto.pm    Module for t/run/switchd.t
 t/lib/Devel/switchd.pm         Module for t/run/switchd.t
 t/lib/feature/bundle           Tests for feature bundles
 t/lib/feature/implicit         Tests for implicit loading of feature.pm
index ff9f97b..4c684d2 100644 (file)
@@ -98,6 +98,13 @@ C<&DB::sub>(I<args>) is made instead, with C<$DB::sub> holding the
 name of the called subroutine. (This doesn't happen if the subroutine
 was compiled in the C<DB> package.)
 
+=item *
+
+When execution of the program uses C<goto> to enter a non-XS
+subroutine and the 0x80 bit is set in C<$^P>, a call to C<&DB::goto>
+is made, with C<$DB::sub> holding the name of the subroutine being
+entered.
+
 =back
 
 Note that if C<&DB::sub> needs external data for it to work, no
diff --git a/t/lib/Devel/switchd_goto.pm b/t/lib/Devel/switchd_goto.pm
new file mode 100644 (file)
index 0000000..d9df2e2
--- /dev/null
@@ -0,0 +1,6 @@
+package Devel::switchd_goto;
+package DB;
+sub DB { $^P |= 0x80; }
+sub goto { print "goto<$DB::sub>;" }
+1;
+
index b3a7364..e71de68 100644 (file)
@@ -9,7 +9,7 @@ BEGIN { require "./test.pl"; }
 
 # This test depends on t/lib/Devel/switchd*.pm.
 
-plan(tests => 13);
+plan(tests => 14);
 
 my $r;
 
@@ -200,3 +200,14 @@ like(
      'PERL5DB with embedded newlines',
     );
 }
+
+# test that DB::goto works
+is(
+  runperl(
+   switches => [ '-Ilib', '-d:switchd_goto' ],
+   prog => 'sub baz { print qq|hello;| } sub foo { goto &baz } foo()',
+   stderr => 1,
+  ),
+  "goto<main::baz>;hello;",
+  "DB::goto"
+);