diff options
-rw-r--r-- | mulkutils-tests.asd | 7 | ||||
-rw-r--r-- | tests.lisp | 63 |
2 files changed, 70 insertions, 0 deletions
diff --git a/mulkutils-tests.asd b/mulkutils-tests.asd new file mode 100644 index 0000000..a296a71 --- /dev/null +++ b/mulkutils-tests.asd @@ -0,0 +1,7 @@ +(defsystem "mulkutils-tests" + :description "Unit tests for Matthias Benkard's Mulkutils." + :author "Matthias Benkard <matthias@benkard.de>" + :licence "GNU General Public License, version 2 or higher" + :depends-on (:mulkutils :lift) + :components ((:file "tests")) + :serial t) diff --git a/tests.lisp b/tests.lisp new file mode 100644 index 0000000..b0f8ed6 --- /dev/null +++ b/tests.lisp @@ -0,0 +1,63 @@ +(defpackage #:mulk.tests + (:use #:cl #:lift #:mulk.lambda)) +(in-package #:mulk.tests) + + +(deftestsuite mulk-lambda () + ()) + + +(deftestsuite mulk-lambda-basic (mulk-lambda) + () + (:equality-test #'equal) + (:tests + ((ensure (functionp (fn #'+ _ 10)))) + ((ensure (functionp (fn (+ _ 10))))) + ((ensure (functionp (fn #'+ _0 _1)))) + ((ensure (functionp (fn #'+ _ _1)))) + ((ensure (functionp (fn #'+ _ (/ _1 2))))) + ((ensure (functionp (fn #'+ _ (/ _1 2))))) + ((ensure-same (mapcar (fn (cons _ _)) '(1 2 3)) + '((1 . 1) (2 . 2) (3 . 3)))) + ((ensure-same (funcall (fn (+ _ 10 _3)) 20 30 40 50) + 80)) + ((ensure-same (funcall (fn (if (zerop _) t nil)) 0) + t)))) + + +(deftestsuite mulk-lambda-fn1 (mulk-lambda) + () + (:tests + ((ensure (= (funcall (fn () _) 42) + 42))) + ((ensure-error (funcall (fn _) 42))) + ((ensure (= (funcall (fn1 _) 42) + 42))) + ((ensure-error (funcall (fn +)))) + ((ensure (eql (funcall (fn1 +)) + +))) + ((ensure (= (funcall (fn #'+)) + 0))) + ((ensure (functionp (funcall (fn1 #'+))))))) + + +(deftestsuite mulk-lambda-efn (mulk-lambda) + () + (:tests + ((ensure (functionp (funcall (fn (fn () _)))))) + ((ensure-error (funcall (efn (efn () _))))) + ((ensure (functionp (funcall (fn1 (fn1 _)))))) + ((ensure-error (funcall (efn1 (efn1 _))))))) + + +(deftestsuite mulk-lambda-fn* (mulk-lambda) + () + #+nil + (:tests + ((ensure-same (funcall (fn* #'+ 1) 2) + 3)) + ((ensure-same (funcall (fn* #'+) 1 2) + 3)) + ((ensure-same (funcall (fn* (/ (* _ 4))) 3 6) + 2)))) + |