Add tests for all the fixnum operations. This only checks that the operations have types; semantics and completely specified types aren't rigourously checked.
svn: r18523 original commit: 97924ffc65b5b5ded6f2b4436cde51ed00462e03
This commit is contained in:
parent
2545da16a9
commit
19cdb4f096
40
collects/tests/typed-scheme/succeed/fixnum.ss
Normal file
40
collects/tests/typed-scheme/succeed/fixnum.ss
Normal file
|
@ -0,0 +1,40 @@
|
|||
#lang typed/scheme
|
||||
|
||||
(require
|
||||
scheme/fixnum)
|
||||
|
||||
;; Test the all the fixnum operations have been wrapped with types
|
||||
|
||||
;; We aren't really testing the semantics of the
|
||||
;; operations. The checks are just to catch anything that is
|
||||
;; really badly wrong.
|
||||
|
||||
(: check (All (a) ((a a -> Boolean) a a -> Boolean)))
|
||||
;; Simple check function as SchemeUnit doesn't work in Typed Scheme (yet)
|
||||
(define (check f a b)
|
||||
(if (f a b)
|
||||
#t
|
||||
(error (format "Check (~a ~a ~a) failed" f a b))))
|
||||
|
||||
(check = (fx+ 1 2) 3)
|
||||
(check = (fx- 2 3) -1)
|
||||
(check = (fx* 2 4) 8)
|
||||
(check = (fxquotient 4 2) 2)
|
||||
(check = (fxremainder 4 3) 1)
|
||||
(check = (fxmodulo 10 3) 1)
|
||||
(check = (fxabs -1) 1)
|
||||
(check = (fxand 2 4) (bitwise-and 2 4))
|
||||
(check = (fxior 2 4) (bitwise-ior 2 4))
|
||||
(check = (fxxor 3 5) (bitwise-xor 3 5))
|
||||
(check = (fxnot 4) (bitwise-not 4))
|
||||
(check = (fxlshift 4 2) (arithmetic-shift 4 2))
|
||||
(check = (fxrshift 32 2) (arithmetic-shift 32 -2))
|
||||
|
||||
(check equal? (fx= 1 1) #t)
|
||||
(check equal? (fx< 2 4) #t)
|
||||
(check equal? (fx> 4 2) #t)
|
||||
(check equal? (fx<= 2 2) #t)
|
||||
(check equal? (fx>= 4 4) #t)
|
||||
(check equal? (fxmin 3 2) 2)
|
||||
(check equal? (fxmax 3 4) 4)
|
||||
|
Loading…
Reference in New Issue
Block a user