diff options
| -rw-r--r-- | test/main.lali | 93 |
1 files changed, 89 insertions, 4 deletions
diff --git a/test/main.lali b/test/main.lali index a3e4b9a..25a23cf 100644 --- a/test/main.lali +++ b/test/main.lali @@ -1,40 +1,125 @@ +(set 'success t) + (defun test (test-expr res) + (newline) (princ - (list (fill - ((differ (eval test-expr) res) 'ok) - ('f 'fail)) + (list (fill ((differ (eval test-expr) res) '+) + ('f 'fail)) '--> test-expr)) - (newline)) + (and success + (set 'success (fill ((differ (eval test-expr) res) t) + (f f))))) ;; atom +(test '(atom ()) f) (test '(atom 'a) t) (test '(atom '(x . a)) f) +(test '(atom '(x a)) f) ;(test '(atom 'a) undef) ;; dif +(test '(dif () 'b) t) +(test '(dif () ()) f) (test '(dif 'a 'b) t) (test '(dif 'a 'a) f) (test '(dif 'a '(b . c)) t) +(test '(dif 'a '(b c)) t) (test '(dif '(b . c) '(b . c)) t) +(test '(dif '(b c) '(b c)) t) + +;; differ +(test '(differ 'a ()) t) +(test '(differ () ()) f) +(test '(differ 'a '(b c)) t) +(test '(differ '(a b) '(b c)) t) +(test '(differ '(b . c) '(b . c)) f) +(test '(differ '(b c) '(b c)) f) ;; car +(test '(car ()) ()) +(test '(car '(a)) 'a) (test '(car '(a . b)) 'a) +(test '(car '(a b)) 'a) (test '(car '((a . b) . c)) '(a . b)) ;(test '(car 'a) undef) ;; cdr +(test '(cdr ()) ()) +(test '(cdr '(a)) ()) (test '(cdr '(a . b)) 'b) +(test '(cdr '(a b)) '(b)) (test '(cdr '((a . b) . c)) 'c) ;(test '(cdr 'a) undef) ;; cons +(test '(cons 'a ()) '(a)) (test '(cons 'a 'b) '(a . b)) +(test '(cons 'a '(b)) '(a b)) (test '(cons '(a . b) 'c) '((a . b) . c)) ;; or +(test '(or () 'a) ()) +(test '(or t 'a) t) +(test '(or 'a 'b 'c) 'a) +(test '(or f f t) t) (test '(or t (car 'a)) t) ;(test '(or (car 'a) t) undef) ;; and +(test '(and () 'a) 'a) +(test '(and f 'a) f) +(test '(and 'a 'b 'c) 'c) +(test '(and t t f) f) (test '(and f (car 'a)) f) ;(test '(and (car 'a) f) undef) + +;; cond +(test '(cond (() 'a) (f 'b)) 'a) +(test '(cond (t 'a) (f 'b)) 'a) +(test '(cond (f 'a) (t 'b) (t 'c)) 'b) +(test '(cond (f 'a) (t 'b)) 'b) +(test '(cond (f (car 'a)) (t 'b)) 'b) +;(test '(cond (f 'a) (t (car 'a))) undef) +(test '(cond (f 'a) (f 'b)) n) + +;; fill +(test '(fill (() 'a) (f 'b)) 'b) +(test '(fill (f 'a) (t 'b)) 'a) +(test '(fill (t 'a) (f 'b) (f 'c)) 'b) +(test '(fill (t 'a) (f 'b)) 'b) +(test '(fill (t (car 'a)) (f 'b)) 'b) +;(test '(fill (t 'a) (f (car 'a))) undef) +(test '(fill (t 'a) (t 'b)) n) + +;; final message +(and success (prog + (newline) + (princ '(All with success.)) + (newline))) + +(defmacro clean (x) (newline) (princ '(** macro clean:)) (newline) (print x) (newline) (print x) (newline)) +(defmacro mac (x) (newline) (princ '(** macro:)) (newline) (print x) (newline) (print (eval x)) (newline)) +(defmacro macr (x) (newline) (princ '(** macro reverse:)) (newline) (print (eval x)) (newline) (print x) (newline)) +(defmacro double (x) (newline) (princ '(** double:)) (newline) (print (eval (eval x))) (newline)) +(defun fun (x) (newline) (princ '(** function:)) (newline) (print x) (newline) (print (eval x)) (newline)) +(defun fun1 (x) (newline) (princ '(** function reverse:)) (newline) (print (eval x)) (newline) (print x) (newline)) + +(newline) +(princ '(TEST (and t t f))) +(newline) +(princ '(- unquoted)) +(newline) +(clean (and t t f)) +(mac (and t t f)) +(macr (and t t f)) +(double (and t t f)) +(fun (and t t f)) +(fun1 (and t t f)) +(princ '(- quoted)) +(newline) +(clean '(and t t f)) +(mac '(and t t f)) +(macr '(and t t f)) +(double '(and t t f)) +(fun '(and t t f)) +(fun1 '(and t t f)) |
