From: Rafael Garcia-Suarez Date: Mon, 23 Mar 2009 14:45:55 +0000 (+0100) Subject: Add more tests with an empty hash on the right of ~~ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a37c5e7310aa2e0852ae3dcc39c0d69b41babe6;p=p5sagit%2Fp5-mst-13.2.git Add more tests with an empty hash on the right of ~~ --- diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod index 52a3f87..157b02b 100644 --- a/pod/perlsyn.pod +++ b/pod/perlsyn.pod @@ -688,7 +688,7 @@ entries apply in those cases. Any CodeRef scalar sub truth $b->($a) Hash Hash hash keys identical [sort keys %$a]~~[sort keys %$b] - Array Hash hash slice existence @$a == grep {exists $b->{$_}} @$a + Array Hash hash slice existence[1] @$a == grep {exists $b->{$_}} @$a Regex Hash hash key grep[1] grep /$a/, keys %$b undef Hash always false (undef can't be a key) Any Hash hash entry existence exists $b->{$a} diff --git a/t/op/smartmatch.t b/t/op/smartmatch.t index a8b387b..d336cfc 100644 --- a/t/op/smartmatch.t +++ b/t/op/smartmatch.t @@ -232,7 +232,7 @@ __DATA__ # HASH ref against: # - another hash ref {} {} -! {} {1 => 2} +=! {} {1 => 2} {1 => 2} {1 => 2} {1 => 2} {1 => 3} ! {1 => 2} {2 => 3} @@ -245,7 +245,10 @@ __DATA__ # - an array ref [keys %main::] \%:: ! [] \%:: +! [""] {} +! [] {} [undef] {"" => 1} + [""] {"" => 1} ["foo"] { foo => 1 } ["foo", "bar"] { foo => 1 } ["foo", "bar"] \%hash @@ -256,6 +259,8 @@ __DATA__ # - a regex qr/^(fo[ox])$/ {foo => 1} ! qr/[13579]$/ +{0..99} +! qr/a*/ {} + qr/a*/ {b=>2} # - a string "foo" +{foo => 1, bar => 2} @@ -264,6 +269,7 @@ __DATA__ # - undef ! undef %hash ! undef +{"" => "empty key"} +! undef {} # ARRAY ref against: # - another array ref