X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fseq.pure.lisp;h=18ea6dcf1c14365b223b42ded7d87a9e989e3a93;hb=bfa4310e41dcd011ca9d139f29be1c5757b41378;hp=a36bb350ff1953315e503fa3418e51988026ea4f;hpb=97e52e46f9bcb054eec35a9c326db75993441ca1;p=sbcl.git diff --git a/tests/seq.pure.lisp b/tests/seq.pure.lisp index a36bb35..18ea6dc 100644 --- a/tests/seq.pure.lisp +++ b/tests/seq.pure.lisp @@ -114,3 +114,50 @@ (ignore-errors (count-if #'zerop #(0 a 0 b c) :start 1 :from-end 11)) (declare (ignore v)) (assert (eql (type-error-datum e) 'c))) + +;;; :COUNT may be negative and BIGNUM +(assert (equal (remove 1 '(1 2 3 1) :count 1) '(2 3 1))) +(assert (equal (remove 1 '(1 2 3 1) :count (* 2 most-positive-fixnum)) '(2 3))) +(assert (equal (remove 1 '(1 2 3 1) :count (* -2 most-positive-fixnum)) '(1 2 3 1))) + +;;; bug reported by Wolfgang Jenkner on sbcl-devel 2003-01-04: +;;; embedded calls of SORT do not work +(assert (equal (sort (list 0 0 0) (lambda (x y) (sort (list 0 0 0) #'<) nil)) + '(0 0 0))) +(assert (equal (sort (list 0 0 0 0 0) + (lambda (x y) + (declare (ignore x y)) + (block compare + (sort (make-list 11 :initial-element 1) + (let ((counter 7)) + (lambda (x y) + (declare (ignore x y)) + (when (= (decf counter) 0) + (return-from compare nil)) + t)))))) + '(0 0 0 0 0))) + +;;; miscellaneous sanity checks on stuff which could've been broken by +;;; changes in MERGE-LIST* in sbcl-0.7.11.* +(assert (equal (merge 'list () () '<) ())) +(assert (equal (merge 'list () (list 1) #'< :key 'identity) '(1))) +(assert (equal (merge 'list (list 2) () '>) '(2))) +(assert (equal (merge 'list (list 1 2 4) (list 2 3 7) '<) '(1 2 2 3 4 7))) +(assert (equal (merge 'list (list 1 2 4) (list -2 3 7) #'<) '(-2 1 2 3 4 7))) +(assert (equal (merge 'list (list 1 2 4) (vector -2 3 7) '< :key 'abs) + '(1 2 -2 3 4 7))) +(assert (equal (merge 'list (list 1 -2 4) (list -2 3 7) '< :key #'abs) + '(1 -2 -2 3 4 7))) +(assert (equal (stable-sort (list 1 10 2 12 13 3) '<) '(1 2 3 10 12 13))) +(assert (equal (stable-sort (list 1 10 2 12 13 3) #'< :key '-) + '(13 12 10 3 2 1))) +(assert (equal (stable-sort (list 1 10 2 12 13 3) '> :key #'-) + '(1 2 3 10 12 13))) +(assert (equal (stable-sort (list 1 2 3 -3 -2 -1) '< :key 'abs) + '(1 -1 2 -2 3 -3))) + +;;; CSR broke FILL by not returning the sequence argument in a transform. +(let* ((s1 (copy-seq "abcde")) + (s2 (fill s1 #\z))) + (assert s2) + (assert (string= s2 "zzzzz")))