use Config;
-plan tests => 67;
+plan tests => 68;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
cmp_ok($sv1-$sv0, '<=', ($n-1)*$delta, @rest);
}
-# Like leak, but run a string eval instead; takes into account existing
-# string eval leaks under -Dmad (except when -Dmad leaks two or
-# more SVs). The code is used instead of the test name
+# Like leak, but run a string eval instead.
+# The code is used instead of the test name
# if the name is absent.
sub eleak {
my ($n,$delta,$code,@rest) = @_;
- leak $n, $delta + !!$Config{mad}, sub { eval $code },
+ leak $n, $delta, sub { eval $code },
@rest ? @rest : $code
}
# [perl #114356] run-time rexexp with unchanging pattern got
# inflated refcounts
+eleak(2, 0, q{ my $x = "x"; "abc" =~ /$x/ for 1..5 }, '#114356');
-SKIP: {
- skip "disabled under -Dmad (eval leaks)" if $Config{mad};
- leak(2, 0, sub { eval q{ my $x = "x"; "abc" =~ /$x/ for 1..5 } }, '#114356');
-}
-
+eleak(2, 0, 'sub', '"sub" with nothing following');
eleak(2, 0, '+sub:a{}', 'anon subs with invalid attributes');
eleak(2, 0, 'no warnings; sub a{1 1}', 'sub with syntax error');
eleak(2, 0, 'no warnings; sub {1 1}', 'anon sub with syntax error');
', 'unterminated here-doc in quotes in multiline eval');
eleak(2, 0, '"${<<END
}"', 'unterminated here-doc in multiline quotes in eval');
-leak(2, !!$Config{mad}, sub { eval { do './op/svleak.pl' } },
+leak(2, 0, sub { eval { do './op/svleak.pl' } },
'unterminated here-doc in file');
eleak(2, 0, 'tr/9-0//');
eleak(2, 0, 'tr/a-z-0//');
'bareword followed by number');
eleak(2, 0, '//dd;'x20, '"too many errors" when parsing m// flags');
eleak(2, 0, 's///dd;'x20, '"too many errors" when parsing s/// flags');
-eleak(2, !!$Config{mad}, 'no warnings; 2 2;BEGIN{}',
+eleak(2, 0, 'no warnings; 2 2;BEGIN{}',
'BEGIN block after syntax error');
{
local %INC; # in case Errno is already loaded
sub FIRSTKEY { keys %{$_[0][0]}; each %{$_[0][0]} }
sub NEXTKEY { each %{$_[0][0]} }
}
-leak(2,!!$Config{mad}, sub {
+leak(2, 0, sub {
eval q`
BEGIN {
$hhtie::explosive = 0;
# Run-time regexp code blocks
{
use re 'eval';
- my $madness = !!$Config{mad};
my @tests = ('[(?{})]','(?{})');
for my $t (@tests) {
- leak(2, $madness, sub {
+ leak(2, 0, sub {
/ $t/;
}, "/ \$x/ where \$x is $t does not leak");
- leak(2, $madness, sub {
+ leak(2, 0, sub {
/(?{})$t/;
}, "/(?{})\$x/ where \$x is $t does not leak");
}
#ifdef PERL_MAD
while (PL_bufptr != PL_bufend &&
PL_bufptr[0] == '\\' && PL_bufptr[1] == 'E') {
- if (!PL_thiswhite)
+ if (PL_madskills) {
+ if (!PL_thiswhite)
PL_thiswhite = newSVpvs("");
- sv_catpvn(PL_thiswhite, PL_bufptr, 2);
+ sv_catpvn(PL_thiswhite, PL_bufptr, 2);
+ }
PL_bufptr += 2;
}
#else
s = PL_bufptr + 1;
if (s[1] == '\\' && s[2] == 'E') {
#ifdef PERL_MAD
- if (!PL_thiswhite)
+ if (PL_madskills) {
+ if (!PL_thiswhite)
PL_thiswhite = newSVpvs("");
- sv_catpvn(PL_thiswhite, PL_bufptr, 4);
+ sv_catpvn(PL_thiswhite, PL_bufptr, 4);
+ }
#endif
PL_bufptr = s + 3;
PL_lex_state = LEX_INTERPCONCAT;
case ' ': case '\t': case '\f': case 013:
#ifdef PERL_MAD
PL_realtokenstart = -1;
- if (!PL_thiswhite)
+ if (PL_madskills) {
+ if (!PL_thiswhite)
PL_thiswhite = newSVpvs("");
- sv_catpvn(PL_thiswhite, s, 1);
+ sv_catpvn(PL_thiswhite, s, 1);
+ }
#endif
s++;
goto retry;
force_next(formbrack ? '.' : '}');
if (formbrack) LEAVE;
#ifdef PERL_MAD
- if (!PL_thistoken)
+ if (PL_madskills && !PL_thistoken)
PL_thistoken = newSVpvs("");
#endif
if (formbrack == 2) { /* means . where arguments were expected */
SV *tmpwhite = 0;
char *tstart = SvPVX(PL_linestr) + PL_realtokenstart;
- SV *subtoken = newSVpvn_flags(tstart, s - tstart, SvUTF8(PL_linestr));
+ SV *subtoken = PL_madskills
+ ? newSVpvn_flags(tstart, s - tstart, SvUTF8(PL_linestr))
+ : NULL;
PL_thistoken = 0;
d = s;
s += termlen;
#ifdef PERL_MAD
tstart = SvPVX(PL_linestr) + stuffstart;
- if (!PL_thisopen && !keep_delims) {
+ if (PL_madskills && !PL_thisopen && !keep_delims) {
PL_thisopen = newSVpvn(tstart, s - tstart);
stuffstart = s - SvPVX(PL_linestr);
}