From d148b05cbf1fd6122a93b2c9010f7e1625b16bab Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Thu, 12 Jul 2007 16:37:54 +0200 Subject: Add unit tests. darcs-hash:76806ba2c9241d199c246f6065c8c776f418bfb9 --- tests.lisp | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests.lisp (limited to 'tests.lisp') 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)))) + -- cgit v1.2.3