[Bps-public-commit] r13440 - in Carp-REPL: lib/Carp

sartak at bestpractical.com sartak at bestpractical.com
Thu Jun 19 20:53:50 EDT 2008


Author: sartak
Date: Thu Jun 19 20:53:48 2008
New Revision: 13440

Modified:
   Carp-REPL/   (props changed)
   Carp-REPL/lib/Carp/REPL.pm

Log:
 r62749 at dhcp184:  sartak | 2008-06-19 19:53:21 -0500
 Add a "test" option so that you can get a REPL as soon as we get a failing test


Modified: Carp-REPL/lib/Carp/REPL.pm
==============================================================================
--- Carp-REPL/lib/Carp/REPL.pm	(original)
+++ Carp-REPL/lib/Carp/REPL.pm	Thu Jun 19 20:53:48 2008
@@ -12,10 +12,24 @@
 sub import {
     my $nodie  = grep { $_ eq 'nodie'    } @_;
     my $warn   = grep { $_ eq 'warn'     } @_;
+    my $test   = grep { $_ eq 'test'     } @_;
     $noprofile = grep { $_ eq 'noprofile'} @_;
 
     $SIG{__DIE__}  = \&repl unless $nodie;
     $SIG{__WARN__} = \&repl if $warn;
+
+    if ($test) {
+        require Test::Builder;
+        my $ok = \&Test::Builder::ok;
+
+        no warnings 'redefine';
+        *Test::Builder::ok = sub {
+            local $Test::Builder::Level = $Test::Builder::Level + 1;
+            my $passed = $ok->(@_);
+            repl() if !$passed;
+            return $passed;
+        };
+    }
 }
 
 sub repl {



More information about the Bps-public-commit mailing list