Commit | Line | Data |
---|---|---|
bc795616 | 1 | #!perl |
f3365a56 | 2 | use strict; |
bc795616 | 3 | use warnings; |
f3365a56 | 4 | |
4aaee9b8 | 5 | BEGIN { chdir 't'; require './test.pl'; } |
f3365a56 | 6 | |
4aaee9b8 | 7 | plan(tests => 8); |
f3365a56 NC |
8 | |
9 | { | |
10 | no warnings 'deprecated'; | |
11 | print <<; # Yow! | |
12 | ok 1 | |
13 | ||
14 | # previous line intentionally left blank. | |
15 | ||
16 | my $yow = "ok 2"; | |
17 | print <<; # Yow! | |
18 | $yow | |
19 | ||
20 | # previous line intentionally left blank. | |
21 | } | |
22 | ||
23 | curr_test(3); | |
bc795616 JV |
24 | |
25 | ||
26 | { | |
27 | my %foo = (aap => "monkey"); | |
28 | my $foo = ''; | |
29 | is("@{[$foo{'aap'}]}", 'monkey', 'interpolation of hash lookup with space between lexical variable and subscript'); | |
30 | is("@{[$foo {'aap'}]}", 'monkey', 'interpolation of hash lookup with space between lexical variable and subscript - test for [perl #70091]'); | |
31 | ||
32 | # Original bug report [perl #70091] | |
33 | # #!perl | |
34 | # use warnings; | |
35 | # my %foo; | |
36 | # my $foo = ''; | |
37 | # (my $tmp = $foo) =~ s/^/$foo {$0}/e; | |
38 | # __END__ | |
39 | # | |
40 | # This program causes a segfault with 5.10.0 and 5.10.1. | |
41 | # | |
42 | # The space between '$foo' and '{' is essential, which is why piping | |
43 | # it through perl -MO=Deparse "fixes" it. | |
44 | # | |
45 | ||
46 | } | |
47 | ||
58b85e8b FC |
48 | { |
49 | delete local $ENV{PERL_UNICODE}; | |
50 | fresh_perl_is( | |
67a057d6 FC |
51 | 'BEGIN{ ++$_ for @INC{"charnames.pm","_charnames.pm"} } "\N{a}"', |
52 | 'Constant(\N{a}) unknown at - line 1, within string' . "\n" | |
53 | ."Execution of - aborted due to compilation errors.\n", | |
54 | { stderr => 1 }, | |
55 | 'correct output (and no crash) when charnames cannot load for \N{...}' | |
58b85e8b FC |
56 | ); |
57 | } | |
67a057d6 FC |
58 | fresh_perl_is( |
59 | 'BEGIN{ ++$_ for @INC{"charnames.pm","_charnames.pm"}; | |
60 | $^H{charnames} = "foo" } "\N{a}"', | |
61 | "Undefined subroutine &main::foo called at - line 2.\n" | |
62 | ."Propagated at - line 2, within string\n" | |
63 | ."Execution of - aborted due to compilation errors.\n", | |
64 | { stderr => 1 }, | |
65 | 'no crash when charnames cannot load and %^H holds string' | |
66 | ); | |
67 | fresh_perl_is( | |
6d70c686 FC |
68 | 'BEGIN{ ++$_ for @INC{"charnames.pm","_charnames.pm"}; |
69 | $^H{charnames} = \"foo" } "\N{a}"', | |
d2192f4f FC |
70 | "Not a CODE reference at - line 2.\n" |
71 | ."Propagated at - line 2, within string\n" | |
67a057d6 FC |
72 | ."Execution of - aborted due to compilation errors.\n", |
73 | { stderr => 1 }, | |
74 | 'no crash when charnames cannot load and %^H holds string reference' | |
75 | ); | |
4aaee9b8 FC |
76 | |
77 | # not fresh_perl_is, as it seems to hide the error | |
78 | is runperl( | |
79 | nolib => 1, # -Ilib may also hide the error | |
80 | progs => [ | |
81 | '*{', | |
82 | ' XS::APItest::gv_fetchmeth_type()', | |
83 | '}' | |
84 | ], | |
85 | stderr => 1, | |
86 | ), | |
87 | "Undefined subroutine &XS::APItest::gv_fetchmeth_type called at -e line " | |
88 | ."2.\n", | |
89 | 'no buffer corruption with multiline *{...expr...}' | |
90 | ; |