X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=t%2Ftests.lisp;h=47a92fcede08751d482f6371d65296309061a43b;hb=168a8cb290c6d9b3fa40e500fd044ecacebb5429;hp=ac2a606e6bd5e26e5c11969204d7a2f52ef51695;hpb=1454981ac5f4f7ea8fe741a8125efbf0b09497ea;p=fiveam.git diff --git a/t/tests.lisp b/t/tests.lisp index ac2a606..47a92fc 100644 --- a/t/tests.lisp +++ b/t/tests.lisp @@ -4,12 +4,17 @@ (in-suite :it.bese.FiveAM) -(def-suite test-suite :description "Suite for tests which should fail.") +(def-suite test-suite + :description "Suite for tests which should fail." + :default-test-args '(:fixture null-fixture :compile-at :run-time)) (defmacro with-test-results ((results test-name) &body body) `(let ((,results (with-*test-dribble* nil (run ',test-name)))) ,@body)) +(def-fixture null-fixture () + `(progn ,@(&body))) + ;;;; Test the checks (test (is1 :suite test-suite) @@ -20,7 +25,7 @@ (is-true t) (is-false nil)) -(test (is2 :suite test-suite) +(test (is2 :suite test-suite :fixture foo) (is (plusp 0)) (is (< 0 -1)) (is (not (plusp 1))) @@ -145,3 +150,50 @@ (run 'circular-1)) (signals circular-dependency (run 'circular-2))) + +(test gen-integer + (for-all ((a (gen-integer))) + (is (integerp a)))) + +(test for-all-guarded + (for-all ((less (gen-integer)) + (more (gen-integer) (< less more))) + (is (< less more)))) + +(test gen-float + (macrolet ((test-gen-float (type) + `(for-all ((unbounded (gen-float :type ',type)) + (bounded (gen-float :type ',type :bound 42))) + (is (typep unbounded ',type)) + (is (typep bounded ',type)) + (is (<= (abs bounded) 42))))) + (test-gen-float single-float) + (test-gen-float short-float) + (test-gen-float double-float) + (test-gen-float long-float))) + +(test gen-character + (for-all ((c (gen-character))) + (is (characterp c))) + (for-all ((c (gen-character :code (gen-integer :min 32 :max 40)))) + (is (characterp c)) + (member c (list #\Space #\! #\" #\# #\$ #\% #\& #\' #\()))) + +(test gen-string + (for-all ((s (gen-string))) + (is (stringp s))) + (for-all ((s (gen-string :length (gen-integer :min 0 :max 2)))) + (is (<= (length s) 2))) + (for-all ((s (gen-string :elements (gen-character :code (gen-integer :min 0 :max 0)) + :length (constantly 2)))) + (is (= 2 (length s))) + (is (every (curry #'char= #\Null) s)))) + +(defun dummy-mv-generator () + (lambda () + (list 1 1))) + +(test for-all-destructuring-bind + (for-all (((a b) (dummy-mv-generator))) + (is (= 1 a)) + (is (= 1 b))))