Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[t] merged statements/grepa-and-sort-in-for.t into spec/S04-statement…

…s/for.t

git-svn-id: http://svn.pugscode.org/pugs@22083 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 764328fcf24fd69d912e3af0b2c04c5e40cd2411 1 parent ee29504
moritz authored
Showing with 37 additions and 1 deletion.
  1. +37 −1 S04-statements/for.t
View
38 S04-statements/for.t
@@ -11,7 +11,7 @@ for statement as possible
=end description
-plan 40;
+plan 43;
## No foreach
# L<S04/The C<for> statement/"no foreach statement any more">
@@ -318,3 +318,39 @@ my @elems = <a b c d e>;
is $gather, '21....1....1....', 'Can mix recursion and for';
}
+# grep and sort in for - these were pugs bugs once, so let's
+# keep them as regression tests
+
+{
+ my @array = <1 2 3 4>;
+ my $output = '';
+
+ for (grep { 1 }, @array) -> $elem {
+ $output ~= "$elem,";
+ }
+
+ is $output, "1,2,3,4,", "grep and sort work in for";
+}
+
+{
+ my @array = <1 2 3 4>;
+ my $output = '';
+
+ for sort @array -> $elem {
+ $output ~= "$elem,";
+ }
+
+ is $output, "1,2,3,4,", "grep and sort work in for";
+}
+
+{
+ my @array = <1 2 3 4>;
+ my $output;
+
+ for (grep { 1 }, sort @array) -> $elem {
+ $output ~= "$elem,";
+ }
+
+ is $output, "1,2,3,4,", "grep and sort work in for";
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.