File: get_NV.t

package info (click to toggle)
libmath-mpfr-perl 4.45-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,716 kB
  • sloc: perl: 1,508; ansic: 517; makefile: 9
file content (88 lines) | stat: -rwxr-xr-x 2,143 bytes parent folder | download | duplicates (6)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use strict;
use warnings;
use Math::MPFR qw(:mpfr);

my $inf = 999**(999**999);
my $nan =  $inf / $inf;
my $real = -93.0176;

if($nan == $nan) {
  warn "\nSkippping all tests - buggy inf and/or nan implementation on this perl\n";
  print "1..1\n";
  print "ok 1\n";
  exit 0;
}

print "1..10\n";

Rmpfr_set_default_prec(200);

my $check = Rmpfr_get_NV(Math::MPFR->new($inf), MPFR_RNDN);
if($check == $inf) {print "ok 1\n"}
else {
  warn "\n Expected $inf, Got $check\n";
  print "not ok 1\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new($nan), MPFR_RNDN);
if($check != $check) {print "ok 2\n"}
else {
  warn "\n Expected NaN, Got $check\n";
  print "not ok 2\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new($real), MPFR_RNDN);
if($check == $real) {print "ok 3\n"}
else {
  warn "\n Expected $real, Got $check\n";
  print "not ok 3\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new('-1.2e4932'), MPFR_RNDN);
if($check == $check && $check != 0 && $check / $check !=1 && $check == ($inf * -1)) {print "ok 4\n"}
else {
  warn "\n Expected -Inf, Got $check\n";
  print "not ok 4\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new(-2.627e123), MPFR_RNDN);
if($check == -2.627e123) {print "ok 5\n"}
else {
  warn "\n Expected -2.627e123, Got $check\n";
  print "not ok 5\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new(-2.627e-123), MPFR_RNDN);
if($check == -2.627e-123) {print "ok 6\n"}
else {
  warn "\n Expected -2.627e-123, Got $check\n";
  print "not ok 6\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new(2.627e123), MPFR_RNDN);
if($check == 2.627e123) {print "ok 7\n"}
else {
  warn "\n Expected 2.627e123, Got $check\n";
  print "not ok 7\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new(2.627e-123), MPFR_RNDN);
if($check == 2.627e-123) {print "ok 8\n"}
else {
  warn "\n Expected 2.627e-123, Got $check\n";
  print "not ok 8\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new('-6.2e-4967'), MPFR_RNDN);
if($check == 0.0) {print "ok 9\n"}
else {
  warn "\n Expected zero, Got $check\n";
  print "not ok 9\n";
}

$check = Rmpfr_get_NV(Math::MPFR->new(), MPFR_RNDN);
if($check != $check) {print "ok 10\n"}
else {
  warn "\n Expected NaN, Got $check\n";
  print "not ok 10\n";
}