Fix [perl #66970] Incorrect coderef in MODIFY_CODE_ATTRIBUTES
[p5sagit/p5-mst-13.2.git] / ext / List-Util / t / maxstr.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(maxstr);
19
cf083cf9 20my $v;
f4a2945e 21
cf083cf9 22ok(defined &maxstr, 'defined');
f4a2945e 23
cf083cf9 24$v = maxstr('a');
25is($v, 'a', 'single arg');
f4a2945e 26
cf083cf9 27$v = maxstr('a','b');
28is($v, 'b', '2-arg ordered');
f4a2945e 29
cf083cf9 30$v = maxstr('B','A');
31is($v, 'B', '2-arg reverse ordered');
f4a2945e 32
33my @a = map { pack("u", pack("C*",map { int(rand(256))} (0..int(rand(10) + 2)))) } 0 .. 20;
34my @b = sort { $a cmp $b } @a;
cf083cf9 35$v = maxstr(@a);
36is($v, $b[-1], 'random ordered');