don't add #line description when debugger is active
Jesse Luehrs [Thu, 3 Mar 2011 04:03:47 +0000 (22:03 -0600)]
this supposedly lets things like NYTProf report on time spent in evals

lib/Eval/Closure.pm
t/11-debugger.t [new file with mode: 0644]

index 01e1411..74b64a4 100644 (file)
@@ -106,7 +106,7 @@ sub eval_closure {
 
     $args{source} = _line_directive(@args{qw(line description)})
                   . $args{source}
-        if defined $args{description};
+        if defined $args{description} && !($^P & 0x10);
 
     my ($code, $e) = _clean_eval_closure(@args{qw(source environment)});
 
diff --git a/t/11-debugger.t b/t/11-debugger.t
new file mode 100644 (file)
index 0000000..7b97272
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Fatal;
+
+BEGIN { $^P |= 0x210 } # PERLDBf_SUBLINE
+
+use Eval::Closure;
+
+unlike(
+    exception {
+        eval_closure(
+            source      => 'sub { $bar }',
+            description => 'foo',
+        )
+    },
+    qr/#line/,
+    "#line directive isn't added when debugger is active"
+);
+
+
+done_testing;