xref: /openbsd-src/gnu/usr.bin/perl/t/comp/line_debug.t (revision 5759b3d249badf144a6240f7eec4dcf9df003e6b)
1b39c5158Smillert#!./perl
2b39c5158Smillert
3*5759b3d2Safresh1BEGIN { unshift @INC, '.' }
4*5759b3d2Safresh1
5b39c5158Smillertchdir 't' if -d 't';
6b39c5158Smillert
7b39c5158Smillertsub ok {
8b39c5158Smillert    my($test,$ok) = @_;
9b39c5158Smillert    print "not " unless $ok;
10b39c5158Smillert    print "ok $test\n";
116fb12b70Safresh1    $ok;
12b39c5158Smillert}
13b39c5158Smillert
14b39c5158Smillert# The auxiliary file contains a bunch of code that systematically exercises
15b39c5158Smillert# every place that can call lex_next_chunk() (except for the one that's not
16b39c5158Smillert# used by the main Perl parser).
17b39c5158Smillertopen AUX, "<", "comp/line_debug_0.aux" or die $!;
18b39c5158Smillertmy @lines = <AUX>;
19b39c5158Smillertclose AUX;
20b39c5158Smillertmy $nlines = @lines;
21b39c5158Smillert
22b39c5158Smillertprint "1..", 2+$nlines, "\n";
23b39c5158Smillert
24b39c5158Smillert$^P = 0x2;
25b39c5158Smillertdo "comp/line_debug_0.aux";
26b39c5158Smillert
27b39c5158Smillertok 1, scalar(@{"_<comp/line_debug_0.aux"}) == 1+$nlines;
28b39c5158Smillertok 2, !defined(${"_<comp/line_debug_0.aux"}[0]);
29b39c5158Smillert
30b39c5158Smillertfor(1..$nlines) {
316fb12b70Safresh1    if (!ok 2+$_, ${"_<comp/line_debug_0.aux"}[$_] eq $lines[$_-1]) {
326fb12b70Safresh1	print "# Got: ", ${"_<comp/line_debug_0.aux"}[$_]//"undef\n";
336fb12b70Safresh1	print "# Expected: $lines[$_-1]";
346fb12b70Safresh1    }
35b39c5158Smillert}
36b39c5158Smillert
37b39c5158Smillert1;
38