diff --git a/init/tests.lisp b/init/tests.lisp index b30513165413f351fc33836fd8dc23e7fcbfba49..f373cf916217c61ccb73c93d4e4f45362160522c 100644 --- a/init/tests.lisp +++ b/init/tests.lisp @@ -17,12 +17,18 @@ "The number of decimal digits on which floating point number must agree.") +(defparameter *zero-threshold* 1.0d-15 + "Threshold below which a number is tpo be considered zero.") + (defun fp-string (fp &optional (decimal-digits *test-fp-decimal-digits*)) "Format the floating point number as a string for comparison." (if (typep fp 'complex) (list (fp-string (realpart fp)) (fp-string (imagpart fp))) (format nil "~,v,2,0,,,ve" - decimal-digits (if (typep fp 'double-float) #\d #\e) fp))) + decimal-digits (if (typep fp 'double-float) #\d #\e) + (if (< (abs fp) *zero-threshold*) + 0.0d0 + fp)))) (defmacro assert-first-fp-equal (expected form &rest extras) (lisp-unit::expand-assert diff --git a/numerical-integration.lisp b/numerical-integration.lisp index e5d6551817c84aff694238be0ae7a2d496b56a6e..60f66a0daeb2a8c8b7f5a26143692a5ce2065587 100644 --- a/numerical-integration.lisp +++ b/numerical-integration.lisp @@ -1,6 +1,6 @@ ;; Numerical integration ;; Liam Healy, Wed Jul 5 2006 - 23:14 -;; Time-stamp: <2008-02-03 13:22:48EST numerical-integration.lisp> +;; Time-stamp: <2008-02-16 11:07:23EST numerical-integration.lisp> ;; $Id: $ ;;; To do: QAWS, QAWO, QAWF, more tests @@ -232,5 +232,5 @@ (integration-QAG one-sine 0.0d0 pi :gauss15 20 ws))) (lisp-unit:assert-error 'gsl-error - (letm ((ws (integration-workspace ws 20))) + (letm ((ws (integration-workspace 20))) (integration-QAG one-sine 0.0d0 pi :gauss15 50 ws)))) diff --git a/polynomial.lisp b/polynomial.lisp index 3274e5978be4a63e363aee9f480011960c5b2054..8b633f5f7439fe72ab980e3d7c2c1e97fca8947d 100644 --- a/polynomial.lisp +++ b/polynomial.lisp @@ -1,6 +1,6 @@ ;; Polynomials ;; Liam Healy, Tue Mar 21 2006 - 18:33 -;; Time-stamp: <2008-02-05 22:35:20EST polynomial.lisp> +;; Time-stamp: <2008-02-16 11:17:51EST polynomial.lisp> ;; $Id: $ (in-package :gsl) @@ -194,8 +194,8 @@ (lisp-unit:fp-values (solve-cubic -6.0d0 -13.0d0 42.0d0))) ;; This should use double-float-unequal (lisp-unit:assert-equal - '(("-0.902598308594d-17" "-1.000000000000d+00") - ("-0.902598308594d-17" "1.000000000000d+00") + '(("0.000000000000d+01" "-1.000000000000d+00") + ("0.000000000000d+01" "1.000000000000d+00") ("0.100000000000d+01" "0.000000000000d+01")) (lisp-unit:fp-values (solve-cubic-complex -1.0d0 1.0d0 -1.0d0))) (lisp-unit:assert-equal