Skip to content

Commit

Permalink
Add a test ensuring a Hash iterator misuse is not exploding
Browse files Browse the repository at this point in the history
  • Loading branch information
Altai-man committed Jul 6, 2021
1 parent 3f63eeb commit a19e355
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion t/nqp/108-vmhash.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plan(54);
plan(55);

my $backend := nqp::getcomp('nqp').backend.name;

Expand Down Expand Up @@ -234,3 +234,16 @@ todo('Exceptions for iterators NYI on js', 2)
if $backend eq 'js';
ok($msg ne "", 'iterator throws after end');
is($msg, 'Iteration past end of iterator', 'iterator throws correct exception after end');

$msg := "";
try {
my $h := nqp::hash("a", 42);
my $i := nqp::iterator($h);
nqp::deletekey($h, "a");
nqp::shift($i);
CATCH {
nqp::getmessage($_);
}
}

ok($msg eq "", 'No SEGV on a misused hash iterator');

0 comments on commit a19e355

Please sign in to comment.