summaryrefslogtreecommitdiff
path: root/t/comp
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2009-11-25 22:17:52 +0000
committerJesse Vincent <jesse@bestpractical.com>2009-11-25 17:48:05 -0500
commit17cc9359ea8ee1b546aa067b91362160e3c1e1ee (patch)
tree6b56341d1a17cd4f21c87a5693358e1e46835ab1 /t/comp
parent5f61da697ab4e86d3bede8883257b28d30c701ad (diff)
downloadperl-17cc9359ea8ee1b546aa067b91362160e3c1e1ee.tar.gz
perl-5.11.2 breaks NYTProf savesrc option (Lexer API suspected)
Tim Bunce wrote: >The primary issue is the off-by-one error in the array indexing. There's a bit more to it than that. The indexing was off-by-one for *some* places that process a new line, but correct for others, so the saved source as a whole was mangled rather than simply offset. Also, there were some redundant calls to update_debugger_info(), so some lines got saved twice, in some cases off-by-one for one saving and not for the other. The saved source is, therefore, hopelessly broken in 5.11.2. Attached patch fixes the source saving. Includes a new test, which works through all reachable places that source lines get saved. This should close RT #70804. -zefram
Diffstat (limited to 't/comp')
-rw-r--r--t/comp/line_debug.t31
-rw-r--r--t/comp/line_debug_0.aux20
2 files changed, 51 insertions, 0 deletions
diff --git a/t/comp/line_debug.t b/t/comp/line_debug.t
new file mode 100644
index 0000000000..175c71a65e
--- /dev/null
+++ b/t/comp/line_debug.t
@@ -0,0 +1,31 @@
+#!./perl
+
+chdir 't' if -d 't';
+
+sub ok {
+ my($test,$ok) = @_;
+ print "not " unless $ok;
+ print "ok $test\n";
+}
+
+# The auxiliary file contains a bunch of code that systematically exercises
+# every place that can call lex_next_chunk() (except for the one that's not
+# used by the main Perl parser).
+open AUX, "<", "comp/line_debug_0.aux" or die $!;
+my @lines = <AUX>;
+close AUX;
+my $nlines = @lines;
+
+print "1..", 2+$nlines, "\n";
+
+$^P = 0x2;
+do "comp/line_debug_0.aux";
+
+ok 1, scalar(@{"_<comp/line_debug_0.aux"}) == 1+$nlines;
+ok 2, !defined(${"_<comp/line_debug_0.aux"}[0]);
+
+for(1..$nlines) {
+ ok 2+$_, ${"_<comp/line_debug_0.aux"}[$_] eq $lines[$_-1];
+}
+
+1;
diff --git a/t/comp/line_debug_0.aux b/t/comp/line_debug_0.aux
new file mode 100644
index 0000000000..2d31d747aa
--- /dev/null
+++ b/t/comp/line_debug_0.aux
@@ -0,0 +1,20 @@
+$z = 'line one';
+$z
+ =
+ 'multiline statement';
+$z = 'line five';
+$z = '
+ multiline
+ string
+';
+$z = 'line ten';
+$z = <<EOS;
+ multiline
+ heredoc
+EOS
+$z = 'line fifteen';
+format Z =
+ @<<<< multiline format
+ $z
+.
+$z = 'line twenty';