summaryrefslogtreecommitdiff
path: root/lib/builtin.t
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-03 22:42:26 +0000
committerPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-12-08 00:05:15 +0000
commit1dd1944b9e9757d121aa50a03029666ee4a07440 (patch)
tree1e9081530da05cb117aca1104907409d137b80ea /lib/builtin.t
parentd2817bd771b5f4a948f1a5395803b7d795453c07 (diff)
downloadperl-1dd1944b9e9757d121aa50a03029666ee4a07440.tar.gz
Give blessed() the same TRUEBOOL optimisation that ref() has in boolean contexts
Diffstat (limited to 'lib/builtin.t')
-rw-r--r--lib/builtin.t6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/builtin.t b/lib/builtin.t
index dec6b9eae2..e35e8ab393 100644
--- a/lib/builtin.t
+++ b/lib/builtin.t
@@ -85,6 +85,12 @@ package FetchStoreCounter {
is(blessed($arr), undef, 'blessed yields undef for non-object');
is(blessed($obj), "Object", 'blessed yields package name for object');
+
+ # blessed() as a boolean
+ is(blessed($obj) ? "YES" : "NO", "YES", 'blessed in boolean context still works');
+
+ # blessed() appears false as a boolean on package "0"
+ is(blessed(bless [], "0") ? "YES" : "NO", "NO", 'blessed in boolean context handles "0" cornercase');
}
# imports are lexical; should not be visible here