Index: src/pmc/hash.pmc =================================================================== --- src/pmc/hash.pmc (revision 34006) +++ src/pmc/hash.pmc (working copy) @@ -1096,6 +1096,30 @@ hash->entries = elems; } } + + METHOD sanity_check() { + Hash *hash = (Hash*)PMC_struct_val(SELF); + UINTVAL i, j; + + for (i = 0; i <= hash->mask; i++) { + HashBucket * const b = hash->bs + i; + void * const key = b->key; + void * const val = b->value; + + for (j = 0; j <= hash->mask; j++) + if (b == hash->bi[j]) + printf("index #%d maps to bucket #%d\n", j, i); + + if (key) + printf("hash->bs+%d: '%s' => ", i, ((STRING*)key)->strstart); + if (val) + printf("'%s'\n", VTABLE_get_string(INTERP, (PMC*)val)->strstart ); + if (key && !val) + printf(" (null)\n"); + if (!key && !val) + printf("hash->bs+%d: key and value are null\n", i); + } + } } /*