From: Nicholas Clark Date: Wed, 12 Apr 2006 22:49:58 +0000 (+0000) Subject: Add tests for all the other types that %^H serialisation is supposed X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=968f0fcb6eaf743ef3c5200ddfe6f64fde094d47;p=p5sagit%2Fp5-mst-13.2.git Add tests for all the other types that %^H serialisation is supposed to support. In the process, found and corrected a bug. Tests are good, m'kay. p4raw-id: //depot/perl@27780 --- diff --git a/hv.c b/hv.c index a37b26e..f0f9c39 100644 --- a/hv.c +++ b/hv.c @@ -2619,7 +2619,7 @@ Perl_refcounted_he_chain_2hv(pTHX_ const struct refcounted_he *chain) break; case HVrhek_IV: value = (chain->refcounted_he_data[0] & HVrhek_UV) - ? newSViv(chain->refcounted_he_val.refcounted_he_u_iv) + ? newSVuv(chain->refcounted_he_val.refcounted_he_u_iv) : newSViv(chain->refcounted_he_val.refcounted_he_u_uv); break; case HVrhek_PV: diff --git a/t/op/caller.t b/t/op/caller.t index c32b044..d0716be 100644 --- a/t/op/caller.t +++ b/t/op/caller.t @@ -5,7 +5,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan( tests => 65 ); + plan( tests => 71 ); } my @c; @@ -231,4 +231,39 @@ EOE $^H{dooot} = "FIP\0FOP\0FIDDIT\0FAP"; } is(get_dooot(), "FIP\0FOP\0FIDDIT\0FAP", "Can do embedded 0 bytes"); + + BEGIN { + $^H{dooot} = chr 256; + } + is(get_dooot(), chr 256, "Can do Unicode"); + + BEGIN { + $^H{dooot} = -42; + } + is(get_dooot(), -42, "Can do IVs"); + + BEGIN { + $^H{dooot} = ~0; + } + cmp_ok(get_dooot(), '>', 42, "Can do UVs"); +} + +{ + my ($k1, $k2, $k3); + BEGIN { + $k1 = chr 163; + $k2 = $k1; + $k3 = $k1; + utf8::upgrade $k2; + utf8::encode $k3; + + $^H{$k1} = 1; + $^H{$k2} = 2; + $^H{$k3} = 3; + } + + + is(get_hash()->{$k1}, 2, "UTF-8 or not, it's the same"); + is(get_hash()->{$k2}, 2, "UTF-8 or not, it's the same"); + is(get_hash()->{$k3}, 3, "Octect sequences and UTF-8 are distinct"); }