chibi-scheme/tests/snow/repo4/euler/interest-test.sld
Alex Shinn 4e75fbab49 Adding snow tests for advanced package defaults from config.
Adding test-library option to automatically infer tests from libraries.
Processing scribble docs even when we can't load the module.
2015-04-20 00:09:02 +09:00

18 lines
712 B
Scheme

(define-library (euler interest-test)
(export run-tests)
(import (scheme base) (scheme process-context) (euler interest))
(begin
(define (test expect expr)
(cond
((not (or (equal? expect expr)
(and (or (inexact? expect) (inexact? expr))
(let ((a (min expect expr))
(b (max expect expr)))
(< (abs (/ (- a b) b)) 0.000001)))))
(write-string "FAIL\n")
(exit 1))))
(define (run-tests)
(test 2.0 (compound-interest 1 1.0 1 1))
(test 2.25 (compound-interest 1 1.0 1 2))
(test 2.4414 (compound-interest 1 1.0 1 4))
(test 2.71828 (compound-interest 1 1.0 1)))))