Skip to content

Commit

Permalink
min(), max and minmax do take a list without an explicit comparison f…
Browse files Browse the repository at this point in the history
…unction
  • Loading branch information
moritz committed Mar 28, 2011
1 parent 25a71d3 commit 5c48821
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions S32-list/minmax.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 53;
plan 54;

# L<S32::Containers/List/=item min>
# L<S32::Containers/List/=item max>
Expand All @@ -18,7 +18,7 @@ my @array = (5,-3,7,0,1,-9); #NOTICE! The <> don't work like they should, rakudo

# Tests for C<min>:
is @array.min, -9, "basic method form of min works";
dies_ok {min(@array)}, 'min() requires comparison function';
is min(@array), -9, 'min(list)';
#?rakudo skip 'named args'
is min(:by({$^a <=> $^b }), :values(@array)), -9, "basic subroutine form of min works with named args";

Expand Down Expand Up @@ -54,6 +54,8 @@ is max(:values(@array)), 7, "basic subroutine form of max works with named args"
is (@array.max: { $^a <=> $^b }), 7,
"method form of max with identity comparison block works";

is max(@array), 7, 'sub form of max';

#?rakudo skip "Range.max not fully implemented yet"
is ((-10..9).max: { abs $^a <=> abs $^b }), -10,
"method form of max on Ranges taking a comparision block works";
Expand All @@ -76,7 +78,7 @@ is ((1..10).max: { ($_-3) * ($_-5) }), 10,

# Tests for C<minmax>:
is @array.minmax, -9..7, "basic method form of minmax works";
dies_ok {minmax(@array)}, 'minmax() requires comparison function';
is minmax(@array), -9..7, 'minmax(list)';
#?rakudo skip 'named args'
is minmax(:by({$^a <=> $^b }), :values(@array)), -9..7, "basic subroutine form of minmax works with named args";

Expand Down

0 comments on commit 5c48821

Please sign in to comment.