re PR fortran/34192 (NEAREST can return wrong numbers)
authorTobias Burnus <burnus@net-b.de>
Sat, 24 Nov 2007 13:18:27 +0000 (14:18 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 24 Nov 2007 13:18:27 +0000 (14:18 +0100)
2007-11-24  Tobias Burnus  <burnus@net-b.de>

       PR fortran/34192
       * gfortran.dg/nearest_2.f90: Add INF/NAN tests.

From-SVN: r130396

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/nearest_2.f90

index d83f28f2059f3b8c45930e0569594ce0b6948aeb..c09ab0d08b09b934c995b0f85198fdaeba67aa8b 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-24  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/34192
+       * gfortran.dg/nearest_2.f90: Add INF/NAN tests.
+
 2007-11-24  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/33541
index 4bdad31c8c8ca9c5a3643a0be9a5ac7f8fc4cef7..16dfa4469c2316bf9e4cce7d750418a164a9d037 100644 (file)
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-options "-fno-range-check" }
 !
 ! PR fortran/34192
 !
@@ -76,6 +77,15 @@ program test
       /= 42.0) &
     call abort()
 
+  ! INF+ = INF
+  if (nearest(1.0/0.0, 1.0) /= 1.0/0.0) call abort()
+  ! -INF- = -INF
+  if (nearest(-1.0/0.0, -1.0) /= -1.0/0.0) call abort()
+  ! NAN- = NAN
+  if (.not.isnan(nearest(0.0d0/0.0,  1.0))) call abort()
+  ! NAN+ = NAN
+  if (.not.isnan(nearest(0.0d0/0.0, -1.0))) call abort()
+
 ! Double precision
 
   ! 0+ > 0
@@ -144,4 +154,13 @@ program test
   if (nearest(nearest(42.0d0, 1.0), -1.0) &
       /= 42.0d0) &
     call abort()
+
+  ! INF+ = INF
+  if (nearest(1.0d0/0.0d0, 1.0) /= 1.0d0/0.0d0) call abort()
+  ! -INF- = -INF
+  if (nearest(-1.0d0/0.0d0, -1.0) /= -1.0d0/0.0d0) call abort()
+  ! NAN- = NAN
+  if (.not.isnan(nearest(0.0d0/0.0,  1.0))) call abort()
+  ! NAN+ = NAN
+  if (.not.isnan(nearest(0.0d0/0.0, -1.0))) call abort()
 end program test