summaryrefslogtreecommitdiff
path: root/lib/builtin.t
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-03 21:23:00 +0000
committerPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-08 00:05:10 +0000
commitd2817bd771b5f4a948f1a5395803b7d795453c07 (patch)
tree4dcff879f83d688917b30fd34b9d4bd35238c03b /lib/builtin.t
parentb2d0d92ba8eefbcb5afd8e04a8f263b4938f26ef (diff)
downloadperl-d2817bd771b5f4a948f1a5395803b7d795453c07.tar.gz
Add builtin::blessed, refaddr and reftype
Diffstat (limited to 'lib/builtin.t')
-rw-r--r--lib/builtin.t20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/builtin.t b/lib/builtin.t
index b94cef4e40..dec6b9eae2 100644
--- a/lib/builtin.t
+++ b/lib/builtin.t
@@ -66,7 +66,25 @@ package FetchStoreCounter {
weaken($ref);
undef $arr;
- ok(!defined $ref, 'ref is now undef after arr is cleared');
+ is($ref, undef, 'ref is now undef after arr is cleared');
+}
+
+# reference queries
+{
+ use builtin qw( refaddr reftype blessed );
+
+ my $arr = [];
+ my $obj = bless [], "Object";
+
+ is(refaddr($arr), $arr+0, 'refaddr yields same as ref in numeric context');
+ is(refaddr("not a ref"), undef, 'refaddr yields undef for non-reference');
+
+ is(reftype($arr), "ARRAY", 'reftype yields type string');
+ is(reftype($obj), "ARRAY", 'reftype yields basic container type for blessed object');
+ is(reftype("not a ref"), undef, 'reftype yields undef for non-reference');
+
+ is(blessed($arr), undef, 'blessed yields undef for non-object');
+ is(blessed($obj), "Object", 'blessed yields package name for object');
}
# imports are lexical; should not be visible here