; This is the input file to test your implementations of the xcheck and xeval ; functions. Use this same test data file to test both functions; use the ; appropriate inputing file as the test driver. I.e., to test xcheck, input ; this file using readfile-xcheck-print-loop, defined in ; readfile-xcheck-print.l. To test xeval, input this file using ; readfile-xeval-print-loop, defined in readfile-xeval-print.l ; '(-- BASIC ATOM TESTS --) 10 10.5 "hi" nil t x '(-- ATOMIC XDEFTYPE TESTS --) (xdeftype i int) (xdeftype r real) (xdeftype s string) (xdeftype b bool) (xdeftype t1 t2) (xdeftype t2 t3) (xdeftype t3 i) '(-- COMPOSITE XDEFTYPE TESTS --) (xdeftype a (array int)) (xdeftype a10 (array int 10)) (xdeftype a-10 (array int (-10 10))) (xdeftype rec (record (i int) (r real) (s string) (b bool))) (xdeftype rrec (record (i int) (r real) (s string) (b bool) (rr rec))) (xdeftype u (union (i int) (r real) (s string) (b bool))) (xdeftype f (function ((i int) (j int)) (real))) (xdeftype g (function ((ap a) (rp r) (rrp rr) (fp f)) ;ins ((a10p a10) (a-10p a-10)))) ;outs (xdeftype h (function ((i ?t1) (j ?t2)) ;ins () ;outs (suchthat (equiv ?t1 ?t2)))) ;such that (xdeftype ara (array (record (i int) (a (array int))))) (xdeftype big-one (array (record (a10f a10) (rrecf rrec) (uf u) (ff f)))) (xdeftype big-two (array (record (a10f2 (array int 10)) (rrecf2 (record (i int) (r real) (s string) (b bool) (r rec))) (uf2 (union (i int) (r real) (s string) (b bool))) (ff2 (function ((i int) (j int)) (real)))))) (xdeftype big-three (array (record (a10f3 (array int 10)) (rrecf3 (record (i int) (r real) r)) (uf3 (union (i int) (r real) (s string) (b bool))) (ff3 (function ((i int) (j int)) (real))) (b3 bool)))) '(-- XDEFVAR TESTS --) (xdefvar iv int 10) iv (xdefvar rv real 20.5) rv (xdefvar sv string) sv (xdefvar bv b) bv (xdefvar av a) av (xdefvar av10 a10) av10 (xdefvar av-10 a-10) av-10 (xdefvar recv rec) rv (xdefvar recv2 (record (i int) (r real) (s string) (b bool))) recv2 (xdefvar rrecv rrec) rrecv (xdefvar uv u) uv (xdefvar fv f) fv (xdefvar arav ara) arav (xdefvar b1v big-one) big-one (xdefvar b2v big-two) (xdefvar b3v big-three) '(-- XDEFUN AND XSETQ TESTS --) (xdefun xprint-int ((x int)) (int) (print x)) (xdefun xprint-real ((x real)) (real) (print x)) (xdefun xprint-string ((x string)) (string) (print x)) (xdefun xprint-bool ((x bool)) (bool) (print x)) (xdefun xplus ((i int) (j int)) (int) (+ i j)) (xdefun xtimes ((i int) (j int)) (int) (* i j)) (xdefun ff ((m int) (n int)) (real) (xplus m n) (xtimes m n) 1.5) ;(-- XDEFUN IN WHICH ALL EXPRS TYPE CHECK CORRECTLY --) (xdefun ok ((ip int) (rp real) (sp string) (bv int) (t1p t1) (t3p t3)) () ; Assign constants to parms (xsetq iv 10) (xsetq rv 10.5) (xsetq sv "xyz") ; Assign global vars to parms (xsetq ip iv) (xsetq rp rv) (xsetq sp sv) ; Make sure local type overrides global type (xsetq bv 10) ; Test equivalence of transitive type defs (xsetq t1p 20) (xsetq t3p t1p) ; Assign composite values to array and record types (xsetq av (xquote (1 2 3 4 5 6 7 8 9 10))) (xsetq av10 av) (xsetq recv (xquote (1 1.5 "xyz" t))) (xsetq rrecv (xquote (1 1.5 "abc" t (10 10.5 "def" nil)))) ; Test structural equivalence of composite types (xsetq recv2 recv) (xsetq b1v (xsetq b1v b2v)) ; Test calls to xdefun'd functions. (xsetq iv (xplus 2 2)) (xsetq iv (xplus (xplus (xtimes (xplus iv 10) (xplus iv 20)) (xtimes (xplus iv 30) (xplus iv 40))) 50)) ; Test calls to built-in array functions. (xsetq av (setelem av 4 5)) (xprint-int (index av 4)) (xsetq av10 (setelem av10 4 50)) (xprint-int (index av 4)) (xprint-int (index av10 4)) ; Test calls to built-in record functions. (setfield recv 'r 100.5) (xprint-real (dot recv 'r)) (xprint-string (dot (dot rrecv 'rr) 's)) ; Test complicated built-in function call (xsetq arav (xquote ( (1 (10 11 12)) (2 (20 21 22)) (3 (30 32 31)) ))) (xprint-int (index (dot (index arav 1) 'a) 2)) ; Test function types (xsetq fv ff) (xsetq rv (fv 10 20)) ) ;(-- XDEFUN IN WHICH ALL EXPRS HAVE TYPE CHECK ERRORS --) (xdefun errors ((ip string) (rp bool) (sp int) (bv int) (t1p t1) (t3p t3)) () ; Assign constants to parms (xsetq iv 10.5) (xsetq rv 10) (xsetq sv t) ; Assign global vars to parms (xsetq ip iv) (xsetq rp rv) (xsetq sp sv) ; Make sure local type overrides global type (xsetq bv t) ; Test equivalence of transitive type defs (xsetq t1p "xyz") (xsetq t3p av) ; Assign bogus composite values to array and record types (xsetq av 1) (xsetq av10 2) (xsetq recv 3) (xsetq rrecv 4) ; Test structural equivalence of composite types (xsetq recv2 av) (xsetq b1v b3v) ; Test calls to xdefun'd functions. (xsetq iv (xplus 2.5 "xyz")) (xsetq iv (xplus (xplus (xtimes (xplus iv 10) (xplus iv 20)) (xtimes (xplus iv 30) (xplus iv 40))) "xyz")) ; Test calls to built-in array functions. (xsetq av (setelem av 5.5 5.5)) (xprint-int (index av "xyz")) (xsetq av10 (setelem av10 5.5 "xyz")) (xprint-int (index av recv)) (xprint-int (index recv 5)) ; Test calls to built-in record functions. (setfield av 'r 100.5) (xprint-real (dot recv 'x)) (xprint-string (dot (dot recv 'rr) 's)) ; Test complicated built-in function call (xsetq arav (xquote ( (1 (10 11 12)) (2 (20 21 22)) (3 (30 32 31)) "xyz"))) (xprint-int (index (dot (index arav 2.5) 'b) "xyz")) ; Test function types (xsetq iv ff) (xsetq rv (iv 10 20)) ) '(-- XCOND TESTS --) (xcond ( (eq 1 1) (xsetq iv 10) (xsetq rv 10.5) (xsetq sv "xyz") (xsetq bv "xyz") ) ;Error ( t (xsetq iv 10) (xsetq rv "xyz") ;Error (xsetq sv "xyz") (xsetq bv t) ) ) '(-- XAPPLY TESTS --) (ok 10 20.5 "abc" 30 40 50)