blob: 4a7e68d44871db3febfc5fcd35ae6d469ae51317 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!./perl
@FOO = ('s', 'N/A', 'a', 'NaN', -1, undef, 0, 1);
$expect = ($#FOO+2) * ($#FOO+1);
print "1..$expect\n";
my $ok = 0;
for my $i (0..$#FOO) {
for my $j ($i..$#FOO) {
$ok++;
my $cmp = $FOO[$i] <=> $FOO[$j];
if (!defined($cmp) ||
$cmp == -1 && $FOO[$i] < $FOO[$j] ||
$cmp == 0 && $FOO[$i] == $FOO[$j] ||
$cmp == 1 && $FOO[$i] > $FOO[$j])
{
print "ok $ok\n";
}
else {
print "not ok $ok ($FOO[$i] <=> $FOO[$j]) gives: '$cmp'\n";
}
$ok++;
$cmp = $FOO[$i] cmp $FOO[$j];
if ($cmp == -1 && $FOO[$i] lt $FOO[$j] ||
$cmp == 0 && $FOO[$i] eq $FOO[$j] ||
$cmp == 1 && $FOO[$i] gt $FOO[$j])
{
print "ok $ok\n";
}
else {
print "not ok $ok ($FOO[$i] cmp $FOO[$j]) gives '$cmp'\n";
}
}
}
|