fix result checking for fxdiv

svn: r12938
This commit is contained in:
Matthew Flatt 2008-12-26 13:43:16 +00:00
parent 7835802a04
commit 2083015b65
2 changed files with 13 additions and 4 deletions

View File

@ -62,16 +62,20 @@
(raise-type-error 'fxdiv-and-mod "fixnum" a))
(unless (fixnum? b)
(raise-type-error 'fxdiv-and-mod "fixnum" b))
(div-and-mod a b))
(define-fx div fxdiv (a b) nocheck)
(let-values ([(d m) (div-and-mod a b)])
(check d (implementation-restriction 'div-and-mod d))
(values d m)))
(define-fx div fxdiv (a b) check)
(define-fx mod fxmod (a b) nocheck)
(define (fxdiv0-and-mod0 a b)
(unless (fixnum? a)
(raise-type-error 'fxdiv0-and-mod0 "fixnum" a))
(unless (fixnum? b)
(raise-type-error 'fxdiv0-and-mod0 "fixnum" b))
(div0-and-mod0 a b))
(define-fx div0 fxdiv0 (a b) nocheck)
(let-values ([(d m) (div0-and-mod0 a b)])
(check d (implementation-restriction 'div0-and-mod0 d))
(values d m)))
(define-fx div0 fxdiv0 (a b) check)
(define-fx mod0 fxmod0 (a b) nocheck)
(define-syntax-rule (define-carry fx/carry (a b c) expr)

View File

@ -227,6 +227,11 @@
(test/exn (fxmod0 1 0) &assertion)
(test/exn (fxdiv0-and-mod0 1 0) &assertion)
(test/exn (fxdiv (least-fixnum) -1) &implementation-restriction)
(test/exn (fxdiv-and-mod (least-fixnum) -1) &implementation-restriction)
(test/exn (fxdiv0 (least-fixnum) -1) &implementation-restriction)
(test/exn (fxdiv0-and-mod0 (least-fixnum) -1) &implementation-restriction)
(test (fxnot 0) -1)
(test (fxnot -2) 1)
(test (fxnot 1) -2)