1#!perl -Ilib -d:switchd_empty
2
3BEGIN {
4    $^P = 0x122;
5    chdir 't' if -d 't';
6    @INC = ('../lib', 'lib');
7    require './test.pl';
8}
9
10use strict;
11use warnings;
12no warnings 'redefine';
13
14plan 2;
15
16our @lines;
17sub DB::DB {
18  my ($p, $f, $l) = caller;
19  return unless $f =~ /^\(eval \d+\)\[.*78586\.t:\d+\]/;
20  push @lines, $l;
21}
22
23sub trace_lines {
24    my ($src) = @_;
25    local @lines;
26    eval $src;
27    die if $@;
28    return join " ", @lines;
29}
30
31is trace_lines(<<'END'), "1 3 3 5";
32    ++$b;
33    {
34        ++$b;
35    }
36    ++$b;
37END
38
39is trace_lines(<<'END'), "1 2 3 3 5";
40    ++$b;
41    for (my $a=1; $a <= 2; ++$a) {
42        ++$b;
43    }
44    ++$b;
45END
46
47