From: Jesse Luehrs Date: Thu, 3 Mar 2011 04:03:47 +0000 (-0600) Subject: don't add #line description when debugger is active X-Git-Tag: 0.03~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=04918f808a684de8897789f8eff80880f1e93ec9;p=gitmo%2FEval-Closure.git don't add #line description when debugger is active this supposedly lets things like NYTProf report on time spent in evals --- diff --git a/lib/Eval/Closure.pm b/lib/Eval/Closure.pm index 01e1411..74b64a4 100644 --- a/lib/Eval/Closure.pm +++ b/lib/Eval/Closure.pm @@ -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 index 0000000..7b97272 --- /dev/null +++ b/t/11-debugger.t @@ -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;