summaryrefslogtreecommitdiff
path: root/lib/builtin.t
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-03 13:35:53 +0000
committerPaul Evans <leonerd@leonerd.org.uk>2021-12-04 11:39:22 +0000
commit6ac93b496cce8882a9d5494bfedb84f4da7e0aee (patch)
tree39715c51bfcaf9a851f141a929fb07ae4fc39773 /lib/builtin.t
parent6ae4a6b7932dd745639ff335e83dbc87c63031a1 (diff)
downloadperl-6ac93b496cce8882a9d5494bfedb84f4da7e0aee.tar.gz
Add builtin:: funcs for handling weakrefs
Also, ensure that B::Deparse understands the OA_TARGMY optimisation of OP_ISBOOL
Diffstat (limited to 'lib/builtin.t')
-rw-r--r--lib/builtin.t20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/builtin.t b/lib/builtin.t
index 3338799721..4f4e33a49e 100644
--- a/lib/builtin.t
+++ b/lib/builtin.t
@@ -49,6 +49,26 @@ package FetchStoreCounter {
is($storecount, 1, 'isbool() TARG invokes STORE magic');
}
+# weakrefs
+{
+ use builtin qw( isweak weaken unweaken );
+
+ my $arr = [];
+ my $ref = $arr;
+
+ ok(!isweak($ref), 'ref is not weak initially');
+
+ weaken($ref);
+ ok(isweak($ref), 'ref is weak after weaken()');
+
+ unweaken($ref);
+ ok(!isweak($ref), 'ref is not weak after unweaken()');
+
+ weaken($ref);
+ undef $arr;
+ ok(!defined $ref, 'ref is now undef after arr is cleared');
+}
+
# imports are lexical; should not be visible here
{
my $ok = eval 'true()'; my $e = $@;