1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
################################################################################
#
# Copyright (c) Marcus Holland-Moritz. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
################################################################################
use Test;
BEGIN { plan tests => 12 };
use Tie::Hash::Indexed;
ok(1);
tie %h, 'Tie::Hash::Indexed';
ok(1);
###----------------------------------------------------------------------------
### BUG: Deleting hash values while iterating caused segfaults or panics
###
### Bug spotted by Cristian Cocheci
###----------------------------------------------------------------------------
%h = (
mhx => 1,
abc => 2,
foo => 3,
bar => 4,
);
ok(scalar keys %h, 4);
$i = 1;
while (my($key, $val) = each %h) {
my $v = delete $h{$key};
ok($v, $val);
ok($v, $i++);
}
ok(scalar keys %h, 0);
|