Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GLRify S32-list/map.t
  • Loading branch information
moritz committed Aug 28, 2015
1 parent 1ea8920 commit c10975b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions S32-list/map.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 56;
plan 57;

# L<S32::Containers/"List"/"=item map">

Expand Down Expand Up @@ -115,11 +115,13 @@ should be equivalent to
{
my @a = (1, 2, 3);
my @b = map { hash("v"=>$_, "d" => $_*2) }, @a;
is(+@b, 6, "should be 6 elements (list context)");
is(+@b, 3, "should be 3 elements");

my @c = map { {"v"=>$_, "d" => $_*2} }, @a;
#?niecza todo
is(+@c, 6, "should be 6 elements (bare block)");
is(+@c, 3, "should be 6 elements (bare block)");

is map({("v"=>$_, "d" => $_*2).Slip}, @a).elems, 6, 'flattens with .Slip';
}

# Map with mutating block
Expand All @@ -144,15 +146,15 @@ is( ~((1..3).map: { dbl( $_ ) }),'2 4 6','extern method in map');
my @array = <a b c d>;
my @result = map { (), }, @array;

is +@result, 0, "map works with the map body returning an empty list";
is +@result, 4, "map works with the map body returning an empty list";
}

{
my @array = <a b c d>;
my @empty = ();
my @result = map { @empty }, @array;

is +@result, 0, "map works with the map body returning an empty array";
is +@result, 4, "map works with the map body returning an empty array";
}

{
Expand Down Expand Up @@ -189,7 +191,7 @@ is( ~((1..3).map: { dbl( $_ ) }),'2 4 6','extern method in map');
my @array = <a b c d>;
my @result = map { () }, @array;

is +@result, 0, "map works with the map body returning ()";
is +@result, 4, "map works with the map body returning () for each iteration";
}

# test map with a block that takes more than one parameter
Expand Down

0 comments on commit c10975b

Please sign in to comment.