;; lib/minikanren/tests/selecto.sx — choose an element + rest of list.

(mk-test
  "selecto-enumerate"
  (run*
    q
    (fresh
      (x r)
      (selecto x r (list 1 2 3))
      (== q (list x r))))
  (list
    (list 1 (list 2 3))
    (list 2 (list 1 3))
    (list 3 (list 1 2))))

(mk-test
  "selecto-find-rest"
  (run* q (selecto 2 q (list 1 2 3)))
  (list (list 1 3)))

(mk-test
  "selecto-find-element"
  (run*
    q
    (selecto
      q
      (list 1 3)
      (list 1 2 3)))
  (list 2))

(mk-test
  "selecto-element-not-present-fails"
  (run* q (selecto 99 q (list 1 2 3)))
  (list))

(mk-test
  "selecto-empty-list-fails"
  (run* q (selecto q (list) (list)))
  (list))

(mk-test
  "selecto-singleton"
  (run* q (fresh (x r) (selecto x r (list :only)) (== q (list x r))))
  (list (list :only (list))))

(mk-tests-run!)
