Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tweaks for new non-flattening for loop
  • Loading branch information
TimToady committed Apr 28, 2015
1 parent 50dbbdf commit ee79237
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion S02-types/bag.t
Expand Up @@ -469,7 +469,7 @@ sub showkv($x) {
{
my $string;
my Bag $bag .= new: <foo foo bar>;
for $bag.keys X $bag.keys -> $a, $b {
for flat $bag.keys X $bag.keys -> $a, $b {
$string ~= $a ~ $b;
}
is $string, 'foofoofoobarbarfoobarbar',
Expand Down
8 changes: 4 additions & 4 deletions S04-statements/for.t
Expand Up @@ -46,7 +46,7 @@ for statement as possible
my $str;
my @a = 1..3;
my @b = 4..6;
for zip(@a; @b) -> $x, $y {
for flat zip(@a; @b) -> $x, $y {
$str ~= "($x $y)";
}
is $str, "(1 4)(2 5)(3 6)", 'for zip(@a; @b) -> $x, $y works';
Expand Down Expand Up @@ -284,7 +284,7 @@ class TestClass{ has $.key is rw };
{
my $a = '';
my $b = '';
for 1..3, 4..6 { $a ~= $_.WHAT.gist ; $b ~= Int.gist };
for flat 1..3, 4..6 { $a ~= $_.WHAT.gist ; $b ~= Int.gist };
is($a, $b, 'List context');

$a = '';
Expand Down Expand Up @@ -405,7 +405,7 @@ eval_dies_ok('for(0..5) { }','keyword needs at least one whitespace after it');
my @a = <1 2 3>;
my @b = <4 5 6>;
my $res = '';
for @a Z @b -> $x, $y {
for flat @a Z @b -> $x, $y {
$res ~= " " ~ $x * $y;
}
is $res, " 4 10 18", "Z -ed for loop";
Expand All @@ -415,7 +415,7 @@ eval_dies_ok('for(0..5) { }','keyword needs at least one whitespace after it');
my @a = <1 2 3>;
my $str = '';

for @a Z @a Z @a Z @a Z @a -> $q, $w, $e, $r, $t {
for flat @a Z @a Z @a Z @a Z @a -> $q, $w, $e, $r, $t {
$str ~= " " ~ $q*$w*$e*$r*$t;
}
is $str, " 1 {2**5} {3**5}", "Z-ed for loop with 5 arrays";
Expand Down
4 changes: 2 additions & 2 deletions S12-meta/primitives.t
Expand Up @@ -32,7 +32,7 @@ plan 17;

# Steal methods of Any/Mu for our method cache.
my %cache;
for Any.^method_table.pairs, Mu.^method_table.pairs {
for flat Any.^method_table.pairs, Mu.^method_table.pairs {
%cache{.key} //= .value;
}
Metamodel::Primitives.install_method_cache($type, %cache);
Expand All @@ -42,7 +42,7 @@ plan 17;

method type_check(Mu $, Mu \check) {
$union-type-checks++;
for @!types, Any, Mu {
for flat @!types, Any, Mu {
return True if Metamodel::Primitives.is_type(check, $_);
}
return False;
Expand Down
2 changes: 1 addition & 1 deletion integration/advent2009-day06.t
Expand Up @@ -22,7 +22,7 @@ is (@a >>+>> 2), [3, 4, 5, 6], 'Single scalars extend to the right';
is (3 <<+<< @a), [4, 5, 6, 7], 'Single scalars extend to the left';
is (~<<@a), ["1", "2", "3", "4"], 'Hyperoperator with prefix operator';
is $(@a-copy = @a; @a-copy>>++; @a-copy), [2, 3, 4, 5], 'Hyperoperator with postfix operator';
for @pi Z @pi-sin -> $elem, $elem-sin {
for flat @pi Z @pi-sin -> $elem, $elem-sin {
is_approx $elem.sin, $elem-sin, 'Hyperoperator used to call .sin on each list element';
}
is ((-1, 0, 3, 42)>>.Str), ["-1", "0", "3", "42"], 'Hyperoperator used to call .Str on each list element';
Expand Down
8 changes: 4 additions & 4 deletions integration/advent2009-day07.t
Expand Up @@ -51,15 +51,15 @@ my @array1 = <11 12 13>;
my @array2 = <21 22 23>;

$a = '';
for @array1 Z @array2 -> $one, $two { $a ~= "$one $two " };
for flat @array1 Z @array2 -> $one, $two { $a ~= "$one $two " };
is $a, '11 21 12 22 13 23 ', 'zip with multiple topics';

$a = '';
for ^Inf Z @array -> $index, $item { $a ~= "$index $item " };
for flat ^Inf Z @array -> $index, $item { $a ~= "$index $item " };
is $a, '0 a 1 b 2 c 3 d ', 'infinite upto, zip with multiple topics';

$a = '';
for ^@array.elems Z @array -> $index, $item { $a ~= "$index $item " };
for flat ^@array.elems Z @array -> $index, $item { $a ~= "$index $item " };
is $a, '0 a 1 b 2 c 3 d ', 'elems upto, zip with multiple topics';

$a = '';
Expand All @@ -73,7 +73,7 @@ is $a, '0 a 1 b 2 c 3 d ', '.kv, multiple topics';
my @four = <41 42 43>;

$a = '';
for @one Z @two Z @three Z @four -> $one, $two, $three, $four {
for flat @one Z @two Z @three Z @four -> $one, $two, $three, $four {
$a ~= "$one $two $three $four "
};
is $a, '11 21 31 41 12 22 32 42 13 23 33 43 ', 'multiple iteration';
Expand Down
2 changes: 1 addition & 1 deletion integration/advent2009-day20.t
Expand Up @@ -18,7 +18,7 @@ my @sig-info = \(name => '$i', type => 'Int'),
\(name => '@stuff', type => 'Positional'),
\(name => '$blah', type => 'Any');

for &foo.signature.params Z @sig-info -> $param, $param-info {
for &foo.signature.params Z @sig-info -> ($param, $param-info) {
is $param.name, $param-info<name>, 'Name matches ' ~ $param-info<name>;
is $param.type.perl, $param-info<type>, 'Type matches ' ~ $param-info<type>;
}
Expand Down
2 changes: 1 addition & 1 deletion integration/advent2011-day15.t
Expand Up @@ -33,7 +33,7 @@ for @inputs -> $n {
}
}

for @inputs Z @results Z @expected -> $input, $result, $expected {
for @inputs Z @results Z @expected -> ($input, $result, $expected) {
ok $result ~~ $expected, "handing of $input"
or diag "got: $result";
}
Expand Down
4 changes: 2 additions & 2 deletions integration/advent2014-day16.t
Expand Up @@ -82,15 +82,15 @@ sub say(*@a) { $said = @a>>.gist.join } # don't care about the new line

{
my @a = 'foo','bar',q/'first/,q/second'/;
for qw/ foo bar 'first second' / Z @a -> $string, $result {
for flat qw/ foo bar 'first second' / Z @a -> $string, $result {
say $string;
is $said, $result;
}
}

{
my @a = 'foo','bar',q/first second/;
for qww/ foo bar 'first second' / Z @a -> $string, $result {
for flat qww/ foo bar 'first second' / Z @a -> $string, $result {
say $string;
is $said, $result;
}
Expand Down

0 comments on commit ee79237

Please sign in to comment.