summaryrefslogtreecommitdiff
path: root/t/op/smartmatch.t
diff options
context:
space:
mode:
authorDavid Leadbeater <dgl@dgl.cx>2010-08-28 22:39:58 +0100
committerRafael Garcia-Suarez <rgs@consttype.org>2010-09-07 16:02:59 +0200
commit329a333e7a4ed898282bec7f485751efbea92e8f (patch)
tree58488cbb987c73db35605786b2cac53b495f4e60 /t/op/smartmatch.t
parent90d1f214e03568148fd6495efac0f5614cfc0323 (diff)
downloadperl-329a333e7a4ed898282bec7f485751efbea92e8f.tar.gz
Fix RT #77468: Smart matching on slices
ref_array_or_hash did not take aslice or hslice OPs into account; wrap them in an anonlist so that smart matching has a reference as it expects.
Diffstat (limited to 't/op/smartmatch.t')
-rw-r--r--t/op/smartmatch.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/t/op/smartmatch.t b/t/op/smartmatch.t
index f8a073be56..f14e91ca94 100644
--- a/t/op/smartmatch.t
+++ b/t/op/smartmatch.t
@@ -73,7 +73,7 @@ my %keyandmore = map { $_ => 0 } @keyandmore;
my %fooormore = map { $_ => 0 } @fooormore;
# Load and run the tests
-plan tests => 335;
+plan tests => 351;
while (<DATA>) {
SKIP: {
@@ -484,6 +484,30 @@ __DATA__
@nums { 1, '', 12, '' }
! @nums { 11, '', 12, '' }
+# array slices
+ @nums[0..-1] []
+ @nums[0..0] [1]
+! @nums[0..1] [0..2]
+ @nums[0..4] [1..5]
+
+! undef @nums[0..-1]
+ 1 @nums[0..0]
+ 2 @nums[0..1]
+! @nums[0..1] 2
+
+ @nums[0..1] @nums[0..1]
+
+# hash slices
+ @keyandmore{qw(not)} [undef]
+ @keyandmore{qw(key)} [0]
+
+ undef @keyandmore{qw(not)}
+ 0 @keyandmore{qw(key and more)}
+! 2 @keyandmore{qw(key and)}
+
+ @fooormore{qw(foo)} @keyandmore{qw(key)}
+ @fooormore{qw(foo or more)} @keyandmore{qw(key and more)}
+
# UNDEF
! 3 undef
! 1 undef