use Config;
-print "1..186\n";
+print "1..187\n";
my $test = 1;
sub test (&) {
my $errfile = "terr$$"; $errfile++ while -e $errfile;
my @tmpfiles = ($cmdfile, $errfile);
open CMD, ">$cmdfile"; print CMD $code; close CMD;
- my $cmd = (($^O eq 'VMS') ? "MCR $^X"
+ my $cmd = (($^O eq 'VMS') ? "$^X"
: ($^O eq 'MSWin32') ? '.\perl'
: ($^O eq 'MacOS') ? $^X
: ($^O eq 'NetWare') ? 'perl'
# savestack, due to the early freeing of the anon closure
my $got = runperl(stderr => 1, prog =>
-'sub d {die} my $f; $f = sub {my $x=1; $f = 0; d}; eval{$f->()}; print qw(ok)'
+'sub d {die} my $f; $f = sub {my $x=1; $f = 0; d}; eval{$f->()}; print qq(ok\n)'
);
- test { $got eq 'ok' };
+ test { $got eq "ok\n" };
}
+# After newsub is redefined outside the BEGIN, it's CvOUTSIDE should point
+# to main rather than BEGIN, and BEGIN should be freed.
+
+{
+ my $flag = 0;
+ sub X::DESTROY { $flag = 1 }
+ {
+ my $x;
+ BEGIN {$x = \&newsub }
+ sub newsub {};
+ $x = bless {}, 'X';
+ }
+ test { $flag == 1 };
+}
+
+
+