diff options
Diffstat (limited to 'lib/builtin.t')
-rw-r--r-- | lib/builtin.t | 20 |
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 = $@; |