Skip to content

Commit

Permalink
RT #129363: duckmap preserves structure types (#180)
Browse files Browse the repository at this point in the history
* RT #129363: duckmap preserves structure types

* Correct oversight in duckmap test
  • Loading branch information
cpin authored and zoffixznet committed Nov 9, 2016
1 parent 8737580 commit cbff557
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion S03-metaops/hyper.t
Expand Up @@ -401,7 +401,7 @@ my @e;
is [[2, 3], [4, [5, 6]]]».classify(*.[0]).gist, '({2 => [2], 3 => [3]} {4 => [4], 5 => [[5 6]]})', ".classify is nodal";
is [[2, 3], [4, [5, 6]]]».combinations.gist, "((() (2) (3) (2 3)) (() (4) ([5 6]) (4 [5 6])))", ".combinations is nodal";
is [[2, 3], [4, [5, 6]]]».deepmap(*+1).gist, "([3 4] [5 [6 7]])", ".deepmap is nodal";
is [[2, 3], [4, [5, 6]]]».duckmap(*+1).gist, "((3 4) (5 3))", ".duckmap is nodal";
is [[2, 3], [4, [5, 6]]]».duckmap(*+1).gist, "([3 4] [5 3])", ".duckmap is nodal";
is [[2, 3], [4, [5, 6]]]».eager.gist, "[[(2) (3)] [(4) [(5) (6)]]]", ".eager is nodal";
is [[2, 3], [4, [5, 6]]]».elems.gist, "(2 2)", ".elems is nodal";
is [[2, 3], [4, [5, 6]]]».end.gist, "(1 1)", ".end is nodal";
Expand Down
10 changes: 6 additions & 4 deletions S32-list/duckmap.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 5;
plan 7;

=begin description
Expand All @@ -19,9 +19,11 @@ This test tests C<duckmap>.
my $roles = ((1 but role {method foo {"a"}}), 2, ((3 but role {method foo {"b"}})));
is-deeply $roles.duckmap({.foo}), ("a", 2, ("b")), "duckmap works with roles";

#?rakudo todo "RT #129363 duckmap doesn't preserve structure types"
is-deeply duckmap(-> Int $x { $x ~~ Int ?? $x !! Any }, [1, [2,3], 4]), [1, [2,3], 4],
'duckmap preserves structure types';
is-deeply duckmap({ .elems }, ["a", ["bb", "cc", "d"], []]), [1, 3, 0], "duckmap doesn't consume iterables for defined ops";

#RT #129363 duckmap doesn't preserve structure types"
is-deeply duckmap(-> Int $x { $x ~~ Int ?? $x !! Any }, [1, [2,3], 4]), [1, [2,3], 4], 'duckmap preserves structure types';
is-deeply duckmap(-> Int $x { $x ~~ Int ?? $x + 1 !! Any }, [1, [2,3], 4]), [2, [3,4], 5], 'duckmap preserves structure types';
} #2

# vim: ft=perl6

0 comments on commit cbff557

Please sign in to comment.