summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/op/anonsub.t13
-rw-r--r--t/op/lexsub.t10
2 files changed, 22 insertions, 1 deletions
diff --git a/t/op/anonsub.t b/t/op/anonsub.t
index ceb8d09e84..d65acfe2db 100644
--- a/t/op/anonsub.t
+++ b/t/op/anonsub.t
@@ -98,3 +98,16 @@ print __ANON__;
sub(){3};
EXPECT
42
+########
+# NAME undef &anon giving it a freed GV
+$_ = sub{};
+delete $::{__ANON__};
+undef &$_; # SvREFCNT_dec + inc on a GV with a refcnt of 1
+ # so now SvTYPE(CvGV(anon)) is 0xff == freed
+if (!eval { require B }) { # miniperl, presumably
+ print "__ANON__\n";
+} else {
+ print B::svref_2object($_)->GV->NAME, "\n";
+}
+EXPECT
+__ANON__
diff --git a/t/op/lexsub.t b/t/op/lexsub.t
index 1efcf1c336..d2edb79bab 100644
--- a/t/op/lexsub.t
+++ b/t/op/lexsub.t
@@ -7,7 +7,7 @@ BEGIN {
*bar::is = *is;
*bar::like = *like;
}
-plan 133;
+plan 135;
# -------------------- Errors with feature disabled -------------------- #
@@ -376,6 +376,10 @@ like runperl(
'state subs and DB::sub under -d'
);
}
+# This used to fail an assertion, but only as a standalone script
+is runperl(switches => ['-lXMfeature=:all'],
+ prog => 'state sub x {}; undef &x; print defined &x',
+ stderr => 1), "\n", 'undefining state sub';
# -------------------- my -------------------- #
@@ -719,6 +723,10 @@ pass "pad taking ownership once more of packagified my-sub";
'my subs and DB::sub under -d'
);
}
+# This used to fail an assertion, but only as a standalone script
+is runperl(switches => ['-lXMfeature=:all'],
+ prog => 'my sub x {}; undef &x; print defined &x',
+ stderr => 1), "\n", 'undefining my sub';
# -------------------- Interactions (and misc tests) -------------------- #