;;;; 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 1.0 (cosh 0.0)) (test 0.0 (sinh 0.0)) (test 0.0 (tanh 0.0)) (test 5.0 (hypot -5.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 20.0 (ldexp 5.0 2)) (test 20.0 (scalbn 5.0 2)) (test (values 0.536870912 -30) (frexp 5.0e-10)) ) ;; (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 "Function fpclass" (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 "Function fpclassify" (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))) ) ;;; ;(import (prefix mathh-consts C:)) ;(require-library mathh-consts) ;=> C:sqrt2 C:degree C:ln2 C:log2e C:e (require-extension mathh-consts) (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)) ) ;;; (test-group "Inline failure #1340" (define (factorial x) (gamma (+ 1 x)) ) (test 362880.0 (factorial 9)) ) ;;; (test-end "Mathh") (test-exit)