diff options
author | Yves Orton <demerphq@gmail.com> | 2017-04-23 11:58:24 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2017-04-23 11:58:24 +0200 |
commit | e4343ef32499562ce956ba3cb9cf4454d5d2ff7f (patch) | |
tree | e56359af9d8b657baf6ee9971f0a47d5eb069e07 /t | |
parent | ca7eb79a236b41b7722c6800527f95cd76843eed (diff) | |
download | perl-e4343ef32499562ce956ba3cb9cf4454d5d2ff7f.tar.gz |
Revert "Tweak our hash bucket splitting rules"
This reverts commit 05f97de032fe95cabe8c9f6d6c0a5897b1616194.
Accidentally pushed while waiting for blead-unfreeze.
Diffstat (limited to 't')
-rw-r--r-- | t/op/coreamp.t | 2 | ||||
-rw-r--r-- | t/op/hash.t | 21 | ||||
-rw-r--r-- | t/op/sub_lval.t | 2 |
3 files changed, 7 insertions, 18 deletions
diff --git a/t/op/coreamp.t b/t/op/coreamp.t index 277ac1094a..4b68569c87 100644 --- a/t/op/coreamp.t +++ b/t/op/coreamp.t @@ -639,7 +639,7 @@ SKIP: { my %h = 1..2; &mykeys(\%h) = 1024; - like Hash::Util::bucket_ratio(%h), qr!/(?:1024|2048)\z!, '&mykeys = changed number of buckets allocated'; + like Hash::Util::bucket_ratio(%h), qr|/1024\z|, '&mykeys = changed number of buckets allocated'; eval { (&mykeys(\%h)) = 1025; }; like $@, qr/^Can't modify keys in list assignment at /; } diff --git a/t/op/hash.t b/t/op/hash.t index 0551e03ca2..a0e79c7396 100644 --- a/t/op/hash.t +++ b/t/op/hash.t @@ -163,8 +163,7 @@ sub torture_hash { my ($h2, $h3, $h4); while (keys %$h > 2) { my $take = (keys %$h) / 2 - 1; - my @keys = (sort keys %$h)[0..$take]; - + my @keys = (keys %$h)[0 .. $take]; my $scalar = %$h; delete @$h{@keys}; push @groups, $scalar, \@keys; @@ -179,19 +178,9 @@ sub torture_hash { # Each time this will get emptied then repopulated. If the fill isn't reset # when the hash is emptied, the used count will likely exceed the array - use Devel::Peek; %$h3 = %$h2; - is(join(",", sort keys %$h3),join(",",sort keys %$h2),"$desc (+$count copy) has same keys"); my (undef, $total3) = validate_hash("$desc (+$count copy)", $h3); - # We now only split when we collide on insert AND exceed the load factor - # when we did so. Building a hash via %x=%y means a pseudo-random key - # order inserting into %x, and we may end up encountering a collision - # at a different point in the load order, resulting in a possible power of - # two difference under the current load factor expectations. If this test - # fails then it is probably because DO_HSPLIT was changed, and this test - # needs to be adjusted accordingly. - ok( $total2 == $total3 || $total2*2==$total3 || $total2==$total3*2, - "$desc (+$count copy) array size within a power of 2 of each other"); + is($total3, $total2, "$desc (+$count copy) has same array size"); # This might use fewer buckets than the original %$h4 = %$h; @@ -200,7 +189,7 @@ sub torture_hash { } my $scalar = %$h; - my @keys = sort keys %$h; + my @keys = keys %$h; delete @$h{@keys}; is(scalar %$h, 0, "scalar keys for empty $desc"); @@ -216,11 +205,11 @@ sub torture_hash { while (@groups) { my $keys = pop @groups; ++$h->{$_} foreach @$keys; - my (undef, $total) = validate_hash($desc, $h); + my (undef, $total) = validate_hash("$desc " . keys %$h, $h); is($total, $total0, "bucket count is constant when rebuilding"); is(scalar %$h, pop @groups, "scalar keys is identical when rebuilding"); ++$h1->{$_} foreach @$keys; - validate_hash("$desc copy", $h1); + validate_hash("$desc copy " . keys %$h1, $h1); } # This will fail if the fill count isn't handled correctly on hash split is(scalar %$h1, scalar %$h, "scalar keys is identical on copy and original"); diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t index 099bb649fd..bf1b49cbc1 100644 --- a/t/op/sub_lval.t +++ b/t/op/sub_lval.t @@ -557,7 +557,7 @@ SKIP: { sub keeze : lvalue { keys %__ } %__ = ("a","b"); keeze = 64; - like Hash::Util::bucket_ratio(%__), qr!1/(?:64|128)!, 'keys assignment through lvalue sub'; + is Hash::Util::bucket_ratio(%__), '1/64', 'keys assignment through lvalue sub'; eval { (keeze) = 64 }; like $@, qr/^Can't modify keys in list assignment at /, 'list assignment to keys through lv sub is forbidden'; |