This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
31f69a92acb46c114f551441562b5ceb74209830
[perl5.git] / ext / List / Util / t / minstr.t
1 #!./perl
2
3 BEGIN {
4     unless (-d 'blib') {
5         chdir 't' if -d 't';
6         @INC = '../lib';
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";
11             exit 0;
12         }
13     }
14 }
15
16
17 use List::Util qw(minstr);
18
19 print "1..5\n";
20
21 print "not " unless defined &minstr;
22 print "ok 1\n";
23
24 print "not " unless minstr('a') eq 'a';
25 print "ok 2\n";
26
27 print "not " unless minstr('a','b') eq 'a';
28 print "ok 3\n";
29
30 print "not " unless minstr('B','A') eq 'A';
31 print "ok 4\n";
32
33 my @a = map { pack("u", pack("C*",map { int(rand(256))} (0..int(rand(10) + 2)))) } 0 .. 20;
34 my @b = sort { $a cmp $b } @a;
35 print "not " unless minstr(@a) eq $b[0];
36 print "ok 5\n";