7 require Config; import Config;
8 keys %Config; # Silence warning
9 if ($Config{extensions} !~ /\bList\/Util\b/) {
10 print "1..0 # Skip: List::Util was not built\n";
17 use Test::More tests => 8;
18 use List::Util qw(max);
22 ok(defined &max, 'defined');
25 is($v, 1, 'single arg');
28 is($v, 2, '2-arg ordered');
31 is($v, 2, '2-arg reverse ordered');
33 my @a = map { rand() } 1 .. 20;
34 my @b = sort { $a <=> $b } @a;
36 is($v, $b[-1], '20-arg random order');
38 my $one = Foo->new(1);
39 my $two = Foo->new(2);
40 my $thr = Foo->new(3);
42 $v = max($one,$two,$thr);
43 is($v, 3, 'overload');
45 $v = max($thr,$two,$one);
46 is($v, 3, 'overload');
51 '""' => sub { ${$_[0]} },
52 '+0' => sub { ${$_[0]} },
57 bless \$value, $class;
62 eval { require bignum; } or skip("Need bignum for testing overloading",1);
67 $v = max($v1,$v2,$v1,$v3,$v1);
68 is($v, $v1, 'bigint');