X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fseq.lisp;h=1f2ffc21c21142c2593132d3864ffb407faece36;hb=9a9a53eada042ce6867c32fdb8431632bb87cc15;hp=326b4f774d4b3cc124e97d42f8ad1f1bf729a77d;hpb=66ad0d166c47208bed9dfb786a335d84aed73c3d;p=jscl.git diff --git a/tests/seq.lisp b/tests/seq.lisp index 326b4f7..1f2ffc2 100644 --- a/tests/seq.lisp +++ b/tests/seq.lisp @@ -5,3 +5,17 @@ (test (find 1 (list 2 1 3))) (test (not (find 1 (list 2 2 2)))) (test (not (find 1 (remove 1 (list 1 2 3 1))))) + +(test (equal (remove-if #'zerop '(1 0 2 0 3)) '(1 2 3))) +(test (equal (remove-if-not #'zerop '(1 0 2 0 3)) '(0 0))) + +;; TODO: Rewrite these tests when EQUALP exists and works on vectors +(let ((v1 (remove-if #'zerop #(1 0 2 0 3)))) + (test (and (= (aref v1 0) 1) (= (aref v1 1) 2) (= (aref v1 2) 3)))) +(test (every #'zerop (remove-if-not #'zerop #(1 0 2 0 3)))) + +(let ((nums '(1 2 3 4 5))) + (test (equal (subseq nums 3) '(4 5))) + (test (equal (subseq nums 2 4) '(3 4))) + ; Test that nums hasn't been altered: SUBSEQ should construct fresh lists + (test (equal nums '(1 2 3 4 5))))