diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-09-13 13:13:33 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-09-13 13:13:33 -0700 |
commit | f263a88ea4feb79cec4414ab882882a4d1613dab (patch) | |
tree | 0e5452a9ab5bee0bb7ca7525d6d4f1a0d606a729 /t/op/kvhslice.t | |
parent | c04e41511ad3b5b38eb42fdce1b06e80d9397107 (diff) | |
download | perl-f263a88ea4feb79cec4414ab882882a4d1613dab.tar.gz |
Test kv slices in places that expect %{}
Diffstat (limited to 't/op/kvhslice.t')
-rw-r--r-- | t/op/kvhslice.t | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/t/op/kvhslice.t b/t/op/kvhslice.t index 6ca875de07..bb0f3c16b9 100644 --- a/t/op/kvhslice.t +++ b/t/op/kvhslice.t @@ -8,7 +8,7 @@ BEGIN { # use strict; -plan tests => 38; +plan tests => 43; # simple use cases { @@ -189,3 +189,21 @@ plan tests => 38; ok( !exists $h{e}, "no autovivification" ); } +# keys/value/each treat argument as scalar +{ + my %h = 'a'..'b'; + my %i = (foo => \%h); + my ($k,$v) = each %i{foo=>}; # => suppresses "Scalar better written as" + is $k, 'a', 'key returned by each %hash{key}'; + is $v, 'b', 'val returned by each %hash{key}'; + %h = 1..10; + is join('-', sort keys %i{foo=>}), '1-3-5-7-9', 'keys %hash{key}'; + is join('-', sort values %i{foo=>}), '10-2-4-6-8', 'values %hash{key}'; +} + +# \% prototype expects hash deref +sub nowt_but_hash(\%) {} +eval 'nowt_but_hash %INC{bar}'; +like $@, qr`^Type of arg 1 to main::nowt_but_hash must be hash \(not(?x: + ) key/value hash slice\) at `, + '\% prototype'; |