X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fseq.pure.lisp;h=3819f41acbec0f823af2716b17f17275ecc78bc1;hb=f3491f128307938cc56367f739b8fbf9e5d503b6;hp=eb75013e8f1b15693071062ec3616cb0ee493400;hpb=1ab1dd29f2602c87d404492e588abdf5f6abfbf2;p=sbcl.git diff --git a/tests/seq.pure.lisp b/tests/seq.pure.lisp index eb75013..3819f41 100644 --- a/tests/seq.pure.lisp +++ b/tests/seq.pure.lisp @@ -224,16 +224,16 @@ (second got) ',lambda))))) (test sb-kernel:bounding-indices-bad-error (lambda () - (find :foo '(1 2 3 :foo) :start 1 :end 5))) + (find :foo '(1 2 3 :foo) :start 1 :end 5 :from-end t))) (test sb-kernel:bounding-indices-bad-error (lambda () - (position :foo '(1 2 3 :foo) :start 1 :end 5))) + (position :foo '(1 2 3 :foo) :start 1 :end 5 :from-end t))) (test sb-kernel:bounding-indices-bad-error (lambda () - (find :foo '(1 2 3 :foo) :start 3 :end 0))) + (find :foo '(1 2 3 :foo) :start 3 :end 0 :from-end t))) (test sb-kernel:bounding-indices-bad-error (lambda () - (position :foo '(1 2 3 :foo) :start 3 :end 0))) + (position :foo '(1 2 3 :foo) :start 3 :end 0 :from-end t))) (test type-error (lambda () (let ((list (list 1 2 3 :foo))) @@ -242,3 +242,52 @@ (lambda () (let ((list (list 1 2 3 :foo))) (position :bar (nconc list list))))))) + +(with-test (:name :bug-554385) + ;; FIND-IF shouldn't look through the entire list. + (assert (= 2 (find-if #'evenp '(1 2 1 1 1 1 1 1 1 1 1 1 :foo)))) + ;; Even though the end bounds are incorrect, the + ;; element is found before that's an issue. + (assert (eq :foo (find :foo '(1 2 3 :foo) :start 1 :end 5))) + (assert (= 3 (position :foo '(1 2 3 :foo) :start 1 :end 5)))) + +(with-test (:name (:search :empty-seq)) + (assert (eql 0 + (funcall (compile nil + `(lambda (x) + (declare (optimize (speed 3)) (simple-vector x)) + (search x #()))) + #()))) + (assert (eql 0 + (funcall (compile nil + `(lambda (x) + (declare (optimize (speed 3)) (simple-vector x)) + (search x #(t t t)))) + #()))) + (assert (eql 0 + (funcall (compile nil + `(lambda (x) + (declare (optimize (speed 3)) (simple-vector x)) + (search x #(t t t) :end1 0))) + #(t t t)))) + (assert (eql 0 + (funcall (compile nil + `(lambda (x) + (declare (optimize (speed 3)) (simple-vector x)) + (search x #(t t t) :key nil))) + #()))) + (assert (eql 0 + (funcall (compile nil + `(lambda (x k) + (declare (optimize (speed 3)) (simple-vector x)) + (search x #(t t t) :key k))) + #() nil))) + (assert (eq :ok + (handler-case + (funcall (compile nil + `(lambda (x) + (declare (optimize (speed 3)) (simple-vector x)) + (search x #(t t t) :start2 1 :end2 0 :end1 0))) + #(t t t)) + (sb-kernel:bounding-indices-bad-error () + :ok)))))