}
/* copy the new items down to the destination list */
dst = PL_stack_base + (PL_markstack_ptr[-2] += items) - 1;
- while (items--)
+ while (items-- > 0)
*dst-- = SvTEMP(TOPs) ? POPs : sv_mortalcopy(POPs);
}
LEAVE; /* exit inner scope */
# grep() and map() tests
#
-print "1..27\n";
+print "1..32\n";
$test = 1;
{ $_ & "X" } ("ok $test\n");
$test++;
}
+
+# Tests for "for" in "map" and "grep"
+# Used to dump core, bug [perl #17771]
+
+{
+ my @x;
+ my $y = '';
+ @x = map { $y .= $_ for 1..2; 1 } 3..4;
+ print "# @x,$y\n";
+ print "@x,$y" eq "1 1,1212" ? "ok $test\n" : "not ok $test\n";
+ $test++;
+ $y = '';
+ @x = map { $y .= $_ for 1..2; $y .= $_ } 3..4;
+ print "# @x,$y\n";
+ print "@x,$y" eq "123 123124,123124" ? "ok $test\n" : "not ok $test\n";
+ $test++;
+ $y = '';
+ @x = map { for (1..2) { $y .= $_ } $y .= $_ } 3..4;
+ print "# @x,$y\n";
+ print "@x,$y" eq "123 123124,123124" ? "ok $test\n" : "not ok $test\n";
+ $test++;
+ $y = '';
+ @x = grep { $y .= $_ for 1..2; 1 } 3..4;
+ print "# @x,$y\n";
+ print "@x,$y" eq "3 4,1212" ? "ok $test\n" : "not ok $test\n";
+ $test++;
+ $y = '';
+ @x = grep { for (1..2) { $y .= $_ } 1 } 3..4;
+ print "# @x,$y\n";
+ print "@x,$y" eq "3 4,1212" ? "ok $test\n" : "not ok $test\n";
+ $test++;
+}