From 19cdb4f0965c0eb34fb9c715757db6b0fdcea25f Mon Sep 17 00:00:00 2001 From: Noel Welsh Date: Fri, 12 Mar 2010 12:13:10 +0000 Subject: [PATCH] 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 --- collects/tests/typed-scheme/succeed/fixnum.ss | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 collects/tests/typed-scheme/succeed/fixnum.ss diff --git a/collects/tests/typed-scheme/succeed/fixnum.ss b/collects/tests/typed-scheme/succeed/fixnum.ss new file mode 100644 index 00000000..b9dfc1b9 --- /dev/null +++ b/collects/tests/typed-scheme/succeed/fixnum.ss @@ -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) +