ikarus/scheme/tests/fixnums.ss

33 lines
709 B
Scheme
Raw Normal View History

2007-11-11 20:43:59 -05:00
(library (tests fixnums)
(export test-fxdiv-and-mod)
(import (ikarus))
(define (test-fxdiv-and-mod)
(define (test x1 x2)
(let-values ([(d m) (fxdiv-and-mod x1 x2)])
(printf "(fxdiv-and-mod ~s ~s) = ~s ~s\n" x1 x2 d m)
(assert (= d (fxdiv x1 x2)))
(assert (= m (fxmod x1 x2)))
(assert (<= 0 m))
(assert (< m (abs x2)))
(assert (= x1 (+ (* d x2) m)))))
(test +17 +3)
(test +17 -3)
(test -17 +3)
(test -17 -3)
(test +16 +3)
(test +16 -3)
(test -16 +3)
(test -16 -3)
(test +15 +3)
(test +15 -3)
(test -15 +3)
(test -15 -3)
(test +10 +4)
(test +10 -4)
(test -10 +4)
(test -10 -4)))