Some more tests for \N
[p5sagit/p5-mst-13.2.git] / t / op / hash.t
index 15a336e..9bde518 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 
 use strict;
 
-plan tests => 5;
+plan tests => 6;
 
 my %h;
 
@@ -30,7 +30,7 @@ ok (Internals::HvREHASH(%h), "20 entries triggers rehash");
 
 
 # second part using an emulation of the PERL_HASH in perl, mounting an
-# attack on a prepopulated hash. This is also useful if you need normal
+# attack on a pre-populated hash. This is also useful if you need normal
 # keys which don't contain \0 -- suitable for stashes
 
 use constant MASK_U32  => 2**32;
@@ -42,12 +42,12 @@ use constant START     => "a";
 my %h2 = map {$_ => 1} 'a'..'cc';
 
 ok (!Internals::HvREHASH(%h2), 
-    "starting with pre-populated non-pathalogical hash (rehash flag if off)");
+    "starting with pre-populated non-pathological hash (rehash flag if off)");
 
 my @keys = get_keys(\%h2);
 $h2{$_}++ for @keys;
 ok (Internals::HvREHASH(%h2), 
-    scalar(@keys) . " colliding into the same bucket keys are triggerring rehash");
+    scalar(@keys) . " colliding into the same bucket keys are triggering rehash");
 
 sub get_keys {
     my $hr = shift;
@@ -97,7 +97,7 @@ sub hash {
     for (@c) {
         # (A % M) + (B % M) == (A + B) % M
         # This works because '+' produces a NV, which is big enough to hold
-        # the intermidiate result. We only need the % before any "^" and "&"
+        # the intermediate result. We only need the % before any "^" and "&"
         # to get the result in the range for an I32.
         # and << doesn't work on NV, so using 1 << 10
         $u += ord;
@@ -109,3 +109,12 @@ sub hash {
     $u += $u << 15; $u %= MASK_U32;
     $u;
 }
+
+# This will crash perl if it fails
+
+use constant PVBM => 'foo';
+
+my $dummy = index 'foo', PVBM;
+eval { my %h = (a => PVBM); 1 };
+
+ok (!$@, 'fbm scalar can be inserted into a hash');