summaryrefslogtreecommitdiff
path: root/t/op/defined.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-09-23 06:02:58 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-09-23 06:03:50 -0700
commit518618af9da07b079c1585df2b7c76a1aed0f19c (patch)
treecf07652a1d714b64d2e0b62b1d0720f46e856a00 /t/op/defined.t
parent02a7bbbc28f17133923631eccec205b5a0c2c52d (diff)
downloadperl-518618af9da07b079c1585df2b7c76a1aed0f19c.tar.gz
[perl #97466] Stop defined from propagating ref cx too far
Diffstat (limited to 't/op/defined.t')
-rw-r--r--t/op/defined.t20
1 files changed, 20 insertions, 0 deletions
diff --git a/t/op/defined.t b/t/op/defined.t
new file mode 100644
index 0000000000..7129e47a88
--- /dev/null
+++ b/t/op/defined.t
@@ -0,0 +1,20 @@
+#!perl
+BEGIN {
+ chdir 't';
+ require './test.pl';
+}
+
+plan 5;
+
+sub notdef { undef }
+
+# [perl #97466]
+# These should actually call the sub, instead of testing the sub itself
+ok !defined do { &notdef }, 'defined do { &sub }';
+ok !defined(scalar(42,&notdef)), 'defined(scalar(42,&sub))';
+ok !defined do{();&notdef}, '!defined do{();&sub}';
+
+# Likewise, these should evaluate @array in scalar context
+no warnings "deprecated";
+ok defined($false ? $scalar : @array), 'defined( ... ? ... : @array)';
+ok defined(scalar @array), 'defined(scalar @array)';