(include "#.scm")

(check-eqv? (##fxwrap* 11 33)   363)
(check-eqv? (##fxwrap* 11 -11) -121)
(check-eqv? (##fxwrap* 11 -33) -363)
(check-eqv? (##fxwrap* -11 33) -363)

(check-eqv? (##fxwrap*) 1)
(check-eqv? (##fxwrap* 11) 11)
(check-eqv? (##fxwrap* 11 22) 242)
(check-eqv? (##fxwrap* 11 22 33) 7986)
(check-eqv? (##fxwrap* 11 22 33 44) 351384)

(check-eqv? (fxwrap* 11 33)   363)
(check-eqv? (fxwrap* 11 -11) -121)
(check-eqv? (fxwrap* 11 -33) -363)
(check-eqv? (fxwrap* -11 33) -363)

(check-eqv? (fxwrap*) 1)
(check-eqv? (fxwrap* 11) 11)
(check-eqv? (fxwrap* 11 22) 242)
(check-eqv? (fxwrap* 11 22 33) 7986)
(check-eqv? (fxwrap* 11 22 33 44) 351384)

(check-eqv? (fxwrap* ##max-fixnum 2) -2)
(check-eqv? (fxwrap* ##max-fixnum -2) 2)
(check-eqv? (fxwrap* ##min-fixnum 2) 0)
(check-eqv? (fxwrap* ##min-fixnum -2) 0)
(check-eqv? (fxwrap* -1 ##max-fixnum -1) ##max-fixnum)
(check-eqv? (fxwrap* -1 ##min-fixnum -1) ##min-fixnum)
(check-eqv? (fxwrap* ##max-fixnum ##max-fixnum) 1)
(check-eqv? (fxwrap* ##min-fixnum ##min-fixnum) 0)
(check-eqv? (fxwrap* ##min-fixnum ##max-fixnum) ##min-fixnum)

(check-tail-exn type-exception? (lambda () (fxwrap* 0.0)))
(check-tail-exn type-exception? (lambda () (fxwrap* 0.5)))
(check-tail-exn type-exception? (lambda () (fxwrap* 0.5 9)))
(check-tail-exn type-exception? (lambda () (fxwrap* 9 0.5)))
(check-tail-exn type-exception? (lambda () (fxwrap* 0.5 3 9)))
(check-tail-exn type-exception? (lambda () (fxwrap* 3 0.5 9)))
(check-tail-exn type-exception? (lambda () (fxwrap* 3 9 0.5)))
