Update to Scalar-List-Utils-1.15
[p5sagit/p5-mst-13.2.git] / ext / List / Util / t / min.t
CommitLineData
1bfb5477 1#!./perl
2
f4a2945e 3BEGIN {
1bfb5477 4 unless (-d 'blib') {
f4a2945e 5 chdir 't' if -d 't';
6 @INC = '../lib';
6b05f64e 7 require Config; import Config;
1bfb5477 8 keys %Config; # Silence warning
6b05f64e 9 if ($Config{extensions} !~ /\bList\/Util\b/) {
10 print "1..0 # Skip: List::Util was not built\n";
11 exit 0;
12 }
1bfb5477 13 }
f4a2945e 14}
15
cf083cf9 16use strict;
17use Test::More tests => 5;
f4a2945e 18use List::Util qw(min);
19
cf083cf9 20my $v;
f4a2945e 21
cf083cf9 22ok(defined &min, 'defined');
f4a2945e 23
cf083cf9 24$v = min(9);
25is($v, 9, 'single arg');
f4a2945e 26
cf083cf9 27$v = min (1,2);
28is($v, 1, '2-arg ordered');
f4a2945e 29
cf083cf9 30$v = min(2,1);
31is($v, 1, '2-arg reverse ordered');
f4a2945e 32
33my @a = map { rand() } 1 .. 20;
34my @b = sort { $a <=> $b } @a;
cf083cf9 35$v = min(@a);
36is($v, $b[0], '20-arg random order');