Skip to content

Commit a19e355

Browse files
committed
Add a test ensuring a Hash iterator misuse is not exploding
1 parent 3f63eeb commit a19e355

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

t/nqp/108-vmhash.t

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
plan(54);
1+
plan(55);
22

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

@@ -234,3 +234,16 @@ todo('Exceptions for iterators NYI on js', 2)
234234
if $backend eq 'js';
235235
ok($msg ne "", 'iterator throws after end');
236236
is($msg, 'Iteration past end of iterator', 'iterator throws correct exception after end');
237+
238+
$msg := "";
239+
try {
240+
my $h := nqp::hash("a", 42);
241+
my $i := nqp::iterator($h);
242+
nqp::deletekey($h, "a");
243+
nqp::shift($i);
244+
CATCH {
245+
nqp::getmessage($_);
246+
}
247+
}
248+
249+
ok($msg eq "", 'No SEGV on a misused hash iterator');

0 commit comments

Comments
 (0)