From: Anno Siegel Date: Sun, 26 Feb 2006 23:30:01 +0000 (+0100) Subject: Testing hash key stringification X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3791f55fe376839bdc13891f7e7c9d16d98ee43;p=p5sagit%2Fp5-mst-13.2.git Testing hash key stringification Message-Id: <4871E87D-4B59-40A3-A091-A7A3CFA221CF@mailbox.tu-berlin.de> p4raw-id: //depot/perl@27335 --- diff --git a/t/op/hashassign.t b/t/op/hashassign.t index 7058d75..3fa6c41 100644 --- a/t/op/hashassign.t +++ b/t/op/hashassign.t @@ -8,7 +8,7 @@ BEGIN { # use strict; -plan tests => 213; +plan tests => 215; my @comma = ("key", "value"); @@ -289,3 +289,20 @@ foreach my $chr (60, 200, 600, 6000, 60000) { is( $#$ar, 2, 'scalar + hash assignment in list context' ); is( "@$ar", "0 1 5", '...gets the last values' ); } + +# test stringification of keys +{ + no warnings 'once'; + my @types = qw( SCALAR ARRAY HASH CODE GLOB); + my @refs = ( \ do { my $x }, [], {}, sub {}, \ *x); + my(%h, %expect); + @h{@refs} = @types; + @expect{map "$_", @refs} = @types; + ok (eq_hash(\%h, \%expect), 'unblessed ref stringification'); + + bless $_ for @refs; + %h = (); %expect = (); + @h{@refs} = @types; + @expect{map "$_", @refs} = @types; + ok (eq_hash(\%h, \%expect), 'blessed ref stringification'); +}