;; -*-theme-d-*-

;; Copyright (C) 2018  Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK

(define-proper-program (tests test684)

  (import (standard-library core)
	  (standard-library basic-math)
	  (standard-library extra-math)
	  (standard-library console-io)
	  (tests numerical-test-env))

  (define-simple-proc main (() <none> nonpure)
    (report-test (fmod 6.5 3.5) 3.0)
    (report-test (r-remainder 6.5 3.5) -0.5) 
    (report-test (fma 2.0 2.5 3.5) 8.5)
    (report-test (fmin 6.5 3.5) 3.5)
    (report-test (fmax -1.5 10.0) 10.0)
    (report-test (fdim 6.5 3.5) 3.0)
    (report-test (fdim -6.5 3.5) 0.0)
    (report-test (r-exp2 2.5) 5.656854249492381)
    (report-test (r-expm1 2.5) 11.182493960703473)
    (report-test (r-log2 2.5) 1.321928094887362)
    (report-test (r-log1p 2.5) 1.252762968495368)
    (report-test (logb 4.5) 2.0)
    (report-test (ilogb 4.5) 2)
    (report-test (r-cbrt 10.5) 2.189759569943944)
    (report-test (r-hypot 2.0 -1.5) 2.5)
    (report-test (r-erf 1.5) 0.966105146475311)
    (report-test (r-erfc 1.5) 0.033894853524689)
    (report-test (r-lgamma 1.5) -0.120782237635245)
    (report-test (r-tgamma 1.5) 0.886226925452758)
    (report-test (r-tgamma 5.0) 24.0)
    (report-test (r-nearbyint 1.6) 2.0)
    (report-test (rint 1.6) 2.0)
    (let ((p-frexp (frexp 4.9)))
      (report-test (car p-frexp) 0.6125)
      (report-test (cdr p-frexp) 3))
    (report-test (ldexp 1.75 3) 14.0)
    (report-test (ldexp 1.3 -10) 0.001269531250000)
    (let ((p-modf (modf 10.8 )))
      (report-test (car p-modf) 0.800000000000001)
      (report-test (cdr p-modf) 10.0))
    (report-test (r-nextafter 1.3 2.0) 1.300000000000000)
    (report-test (r-nextafter 1.3 -2.0) 1.300000000000000)
    (report-test (r-copysign -1.5 2.0) 1.5)
    (report-test (r-copysign -1.5 -2.0) -1.5)
    (report-test (fpclassify 1.1) (fpclassify-normal))
    (report-test (fpclassify 0.0) (fpclassify-zero))
    (report-test (fpclassify (nan)) (fpclassify-nan))
    (report-test (fpclassify (inf)) (fpclassify-infinite))
    (report-boolean-test (r-isnormal? 2.0) #t)
    (report-boolean-test (r-isnormal? (inf)) #f)
    (report-boolean-test (r-isnormal? (nan)) #f)
    (report-test (r-signbit 10.0) 0)
    (report-test (r-signbit 0.0) 0)
    (report-test (r-signbit -10.0) 1)))
