Fast generic function dispatch without calling `compile' at runtime
[bpt/guile.git] / test-suite / tests / r6rs-arithmetic-flonums.test
index c5d60ce..c90184d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; arithmetic-flonums.test --- Test suite for R6RS (rnrs arithmetic flonums)
 
-;;      Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+;;      Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
 ;;
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
     (flfinite? 2.0))
 
   (pass-if "flfinite? is #f on infinities"
-    (and (not (flfinite? +inf.0)) (not (flfinite? -inf.0)))))
+    (and (not (flfinite? +inf.0)) (not (flfinite? -inf.0))))
+
+  (pass-if "flfinite? is #f on NaNs"
+    (not (flfinite? +nan.0))))
 
 (with-test-prefix "flinfinite?"
   (pass-if "flinfinite? is #t on infinities"
     (and (fl=? (flnumerator +inf.0) +inf.0)
         (fl=? (flnumerator -inf.0) -inf.0)))
 
-  (pass-if "negative zero" (fl=? (flnumerator -0.0) -0.0)))
+  (pass-if "negative zero" (eqv? (flnumerator -0.0) -0.0)))
 
 (with-test-prefix "fldenominator"
   (pass-if "simple" (fl=? (fldenominator 0.5) 2.0))
 
 (with-test-prefix "fllog"
   (pass-if "unary fllog returns natural log"
-    (let ((l (fllog 2.718281828459045)))
-      (and (fl<=? 0.9 l) (fl>=? 1.1 l))))
+    (reasonably-close? (fllog 2.718281828459045) 1.0))
   
   (pass-if "infinities"
     (and (fl=? (fllog +inf.0) +inf.0)
         (flnan? (fllog -inf.0))))
 
-  (pass-if "zeroes" (fl=? (fllog 0.0) -inf.0))
+  (pass-if "negative argument"
+    (flnan? (fllog -1.0)))
+
+  (pass-if "zero" (fl=? (fllog 0.0) -inf.0))
+  (pass-if "negative zero" (fl=? (fllog -0.0) -inf.0))
+  (pass-if "negative zero with base" (fl=? (fllog -0.0 0.5) +inf.0))
 
   (pass-if "binary fllog returns log in specified base"
     (fl=? (fllog 8.0 2.0) 3.0)))
 (with-test-prefix "flasin" 
   (pass-if "simple"
     (and (reasonably-close? (flasin 1.0) (/ fake-pi 2))
-        (reasonably-close? (flasin 0.5) (/ fake-pi 6)))))
+        (reasonably-close? (flasin 0.5) (/ fake-pi 6))))
+  (pass-if "out of range"
+    (flnan? (flasin 2.0))))
 
 (with-test-prefix "flacos" 
   (pass-if "simple"
     (and (fl=? (flacos 1.0) 0.0)
-        (reasonably-close? (flacos 0.5) (/ fake-pi 3)))))
+        (reasonably-close? (flacos 0.5) (/ fake-pi 3))))
+  (pass-if "out of range"
+    (flnan? (flacos 2.0))))
 
 (with-test-prefix "flatan"
   (pass-if "unary flatan"
 
 (with-test-prefix "flsqrt"
   (pass-if "simple" (fl=? (flsqrt 4.0) 2.0))
-
+  (pass-if "negative" (flnan? (flsqrt -1.0)))
   (pass-if "infinity" (fl=? (flsqrt +inf.0) +inf.0))
-
   (pass-if "negative zero" (fl=? (flsqrt -0.0) -0.0)))
 
-(with-test-prefix "flexpt" (pass-if "simple" (fl=? (flexpt 2.0 3.0) 8.0)))
+(with-test-prefix "flexpt"
+  (pass-if "simple" (fl=? (flexpt 2.0 3.0) 8.0))
+  (pass-if "negative squared" (fl=? (flexpt -2.0 2.0) 4.0))
+  (pass-if "negative cubed" (fl=? (flexpt -2.0 3.0) -8.0))
+  (pass-if "negative to non-integer power" (flnan? (flexpt -2.0 2.5))))
 
 (with-test-prefix "fixnum->flonum"
   (pass-if "simple" (fl=? (fixnum->flonum 100) 100.0)))