Revert "fix sb-posix tests on OpenBSD"
[sbcl.git] / tests / seq.pure.lisp
index eb75013..3819f41 100644 (file)
                            (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)))
           (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)))))