This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
I don't think it's sensible or portable to test the strtou*
[perl5.git] / t / op / cmp.t
CommitLineData
44a8e56a
PP
1#!./perl
2
98a29390 3@FOO = ('s', 'N/A', 'a', 'NaN', -1, undef, 0, 1);
44a8e56a 4
98a29390 5$expect = ($#FOO+2) * ($#FOO+1);
44a8e56a
PP
6print "1..$expect\n";
7
8my $ok = 0;
9for my $i (0..$#FOO) {
10 for my $j ($i..$#FOO) {
11 $ok++;
98a29390
JH
12 my $cmp = $FOO[$i] <=> $FOO[$j];
13 if (!defined($cmp) ||
14 $cmp == -1 && $FOO[$i] < $FOO[$j] ||
15 $cmp == 0 && $FOO[$i] == $FOO[$j] ||
16 $cmp == 1 && $FOO[$i] > $FOO[$j])
44a8e56a
PP
17 {
18 print "ok $ok\n";
19 }
20 else {
98a29390 21 print "not ok $ok ($FOO[$i] <=> $FOO[$j]) gives: '$cmp'\n";
44a8e56a
PP
22 }
23 $ok++;
98a29390
JH
24 $cmp = $FOO[$i] cmp $FOO[$j];
25 if ($cmp == -1 && $FOO[$i] lt $FOO[$j] ||
26 $cmp == 0 && $FOO[$i] eq $FOO[$j] ||
27 $cmp == 1 && $FOO[$i] gt $FOO[$j])
44a8e56a
PP
28 {
29 print "ok $ok\n";
30 }
31 else {
98a29390 32 print "not ok $ok ($FOO[$i] cmp $FOO[$j]) gives '$cmp'\n";
44a8e56a
PP
33 }
34 }
35}