Commit | Line | Data |
aac018bb |
1 | #!./perl -w |
2 | |
3 | # Check that lines from eval are correctly retained by the debugger |
4 | |
5 | BEGIN { |
6 | chdir 't' if -d 't'; |
7 | @INC = '../lib'; |
8 | require "./test.pl"; |
9 | } |
10 | |
11 | use strict; |
12 | |
13 | plan( tests => 10 ); |
14 | |
15 | my @before = grep { /eval/ } keys %::; |
16 | |
17 | is (@before, 0, "No evals"); |
18 | |
19 | for my $sep (' ') { |
20 | $^P = 0xA; |
21 | |
22 | my $prog = "sub foo { |
23 | 'Perl${sep}Rules' |
24 | }; |
25 | 1; |
26 | "; |
27 | |
28 | eval $prog or die; |
29 | # Is there a more efficient way to write this? |
30 | my @expect_lines = (undef, map ({"$_\n"} split "\n", $prog), "\n", ';'); |
31 | |
32 | my @keys = grep { /eval/ } keys %::; |
33 | |
34 | is (@keys, 1, "1 eval"); |
35 | |
36 | my @got_lines = @{$::{$keys[0]}}; |
37 | |
38 | is (@got_lines, @expect_lines, "Right number of lines for " . ord $sep); |
39 | |
40 | for (0..$#expect_lines) { |
41 | is ($got_lines[$_], $expect_lines[$_], "Line $_ is correct"); |
42 | } |
43 | } |