Some more tests for \N
[p5sagit/p5-mst-13.2.git] / t / op / hashassign.t
index 7058d75..3fa6c41 100644 (file)
@@ -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');
+}