summaryrefslogtreecommitdiff
path: root/dist/Math-BigInt/t/nan_cmp.t
blob: 983edcbddc6bea990f18442f9259083c9c821daa (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
36
#!/usr/bin/perl -w

# test that overloaded compare works when NaN are involved

use strict;
use Test::More tests => 26;

use Math::BigInt;
use Math::BigFloat;

compare (Math::BigInt->bnan(),   Math::BigInt->bone() );
compare (Math::BigFloat->bnan(), Math::BigFloat->bone() );

sub compare
  {
  my ($nan, $one) = @_;

  is ($one, $one, '1 == 1');

  is ($one != $nan, 1, "1 != NaN");
  is ($nan != $one, 1, "NaN != 1");
  is ($nan != $nan, 1, "NaN != NaN");

  is ($nan == $one, '', "NaN == 1");
  is ($one == $nan, '', "1 == NaN");
  is ($nan == $nan, '', "NaN == NaN");

  is ($nan <= $one, '', "NaN <= 1");
  is ($one <= $nan, '', "1 <= NaN");
  is ($nan <= $nan, '', "NaN <= NaN");

  is ($nan >= $one, '', "NaN >= 1");
  is ($one >= $nan, '', "1 >= NaN");
  is ($nan >= $nan, '', "NaN >= NaN");
  }