-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugs in clone, sugar methods, and postdec #6
Comments
Think this is related. And it's a really common use case:
The hash ends up being empty. But using the tied interface works as expected.
Since this is a really old bug for a common use case, it should at least be documented. |
Hi David. I also encountered the bug with use strict; use warnings;
use Tie::Hash::Indexed;
use Hash::Ordered;
use MCE::Shared::Ordhash;
# my $hi = Tie::Hash::Indexed->new(total => 0); # all pass
# my $ho = Hash::Ordered->new(total => 0);
# my $oh = MCE::Shared::Ordhash->new(total => 0);
my $hi = Tie::Hash::Indexed->new(); # pass
my $ho = Hash::Ordered->new(); # preinc fails
my $oh = MCE::Shared::Ordhash->new(); # pass
sub task {
my $id = shift;
$hi->set($id => $id); $hi->preinc('total');
$ho->set($id => $id); $ho->preinc('total');
$oh->set($id => $id); $oh->incr('total');
}
task($_) for 1..4;
my (@k, @v);
@k = $hi->keys; print "hi keys: @k\n";
@k = $ho->keys; print "ho keys: @k\n";
@k = $oh->keys; print "oh keys: @k\n";
@v = $hi->values; print "hi vals: @v\n";
@v = $ho->values; print "ho vals: @v\n";
@v = $oh->values; print "oh vals: @v\n";
__END__
# expected results
hi keys: total 1 2 3 4
ho keys: total 1 2 3 4
oh keys: total 1 2 3 4
hi vals: 4 1 2 3 4
ho vals: 4 1 2 3 4
oh vals: 4 1 2 3 4
# ho fails unless setting 'total' to 0 during construction or before running
ho keys: 1 2 3 4
ho vals: 1 2 3 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: