Skip to content

Commit

Permalink
Test assignment to holes when iterating arrays
Browse files Browse the repository at this point in the history
Closes RT#126312.
  • Loading branch information
AlexDaniel committed Apr 7, 2018
1 parent a469bf2 commit d78f339
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion S04-statements/for.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use MONKEY-TYPING;

use Test;

plan 107;
plan 111;

=begin description
Expand Down Expand Up @@ -767,4 +767,17 @@ is (for 5 { (sub { "OH HAI" })() }), "OH HAI", 'Anon sub inside for works.';
is $loops, 5, 'Lazy for loop does no more work than required';
}

# RT#126312
{
my Int @a;
@a[5] = 42;
lives-ok { $_ = 6 for @a }, β€˜holes are mutable (for @a)’;
is @a, <6 6 6 6 6 6>, β€˜holes were changed correctly (for @a)’;

my Int @b;
@b[5] = 24;
lives-ok { $_ = 9 for @b[*] }, β€˜holes are mutable (for @a[*])’;
is @b, <9 9 9 9 9 9>, β€˜holes were changed correctly (for @a[*])’;
}

# vim: ft=perl6

0 comments on commit d78f339

Please sign in to comment.