### ----------------------------------------------------
### -- List::MoreUtils
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/apply.rakutest
### ----------------------------------------------------
use Test;
use List::MoreUtils <apply>;

plan 5;

my @list = 0 .. 9;
my @list1 = apply { $_++ }, @list;
is-deeply @list,  [0 .. 9],  "original numbers untouched";
is-deeply @list1, [1 .. 10], "returned numbers increased";

@list = (" foo ", " bar ", "     ", "foobar");
@list1 = apply { s:g/^ \s+ | \s+ $// }, @list;
is-deeply @list,  [" foo ", " bar ", "     ", "foobar"],
  "original strings untouched";
is-deeply @list1, ["foo",   "bar",   "",      "foobar"],
  "returned strings stripped";

my $ITEM = apply Scalar, { s:g/^ \s+ | \s+ $// }, @list;
is $ITEM, "foobar", "Scalar returns last item";

# vim: expandtab shiftwidth=4


