;;;; mathh-test.scm -*- Scheme -*- ;;;; Kon Lovett, Jul '18 ;;;; Kon Lovett, May '17 (import test) (test-begin "Mathh") ;;; (import (chicken flonum) mathh) ;; (test-group "ISO C Functions" (test 1.0 (bessel-j0 0.0)) (test 0.0 (bessel-j1 0.0)) (test 1.0 (bessel-jn 0 0.0)) (test 0.0 (bessel-jn 1 0.0)) (test 0.088256964215677 (bessel-y0 1.0)) (test -0.781212821300289 (bessel-y1 1.0)) (test 0.088256964215677 (bessel-yn 0 1.0)) (test -0.781212821300289 (bessel-yn 1 1.0)) (test 5.0 (hypot -5.0 0.0)) (test 1.0 (tgamma 1.0)) (test 0.0 (lgamma 1.0)) (test 2.0 (log10 100.0)) (test 3.0 (log2 8.0)) (test 0.0 (log1p 0.0)) (test 0.0 (fpmod 0.0 1.0)) (test (values 5.0 0.5) (modf 5.5)) (test (values 5 0.5) (modf* 5.5)) (test 20.0 (ldexp 5.0 2)) (test 20.0 (scalbn 5.0 2)) (test (values 0.536870912 -30) (frexp 5.0e-10)) ) (cond-expand ((or chicken-5.0 chicken-5.1 chicken-5.2 chicken-5.3 chicken-5.4) (test-group "ISO C h Functions" (test 1.0 (cosh 0.0)) (test 0.0 (sinh 0.0)) (test 0.0 (tanh 0.0)) ) ) (else) ) ;; (test-group "BSD Functions" (test-assert (signbit -1.0)) (test-assert (not (signbit 1.0))) (test-assert (signbit -0.0)) (test -1.0 (copysign 1.0 -1.0)) (test 1.0 (copysign -1.0 1.0)) (test 1.0 (nextafter 1.0 -1.0)) (test -1.0 (nextafter -1.0 1.0)) (test 2.4662 (cbrt 15.0)) ) ;; (test-group "fpclass Function" (test 'negative-infinite (fpclass -inf.0)) (test 'signaling-nan (fpclass -nan.0)) (test 'negative-zero (fpclass -0.0)) (test 'positive-normal (fpclass 0.741573033707865)) (test 'positive-normal (fpclass (fp/ 33.0 44.5))) ) ;; (test-group "fpclassify Function" (test 'infinite (fpclassify -inf.0)) (test 'nan (fpclassify -nan.0)) (test 'zero (fpclassify -0.0)) (test 'normal (fpclassify 0.741573033707865)) (test 'normal (fpclassify (fp/ 33.0 44.5))) ) ;; (include-relative "../mathh-constants") (test-group "Math Constants" ; Well, some (test SQRT2 (sqrt 2.0)) (test DEGREE (/ PI 180.0)) (test LN2 (log 2.0)) (test LOG2E (log2 E)) ) ;; ;(import (prefix mathh-consts C:)) ;(require-library mathh-consts) ;=> C:sqrt2 C:degree C:ln2 C:log2e C:e (import mathh-consts) (test-group "Math Consts" ; Well, some (test sqrt2 (sqrt 2.0)) (test degree (/ pi 180.0)) (test ln2 (log 2.0)) (test log2e (log2 e)) ) ;; (test-group "Inline failure #1340" (define (factorial x) (gamma (+ 1 x)) ) (test 362880.0 (factorial 9)) ) ;;; (test-end "Mathh") (test-exit)