;; lib/minikanren/tests/minmax.sx — mino + maxo via intarith.

(mk-test
  "mino-singleton"
  (run* q (mino (list 7) q))
  (list 7))
(mk-test
  "mino-of-3"
  (run* q (mino (list 5 1 3) q))
  (list 1))
(mk-test
  "mino-of-5"
  (run*
    q
    (mino (list 5 1 3 2 4) q))
  (list 1))
(mk-test
  "mino-with-dups"
  (run* q (mino (list 3 3 3) q))
  (list 3))
(mk-test "mino-empty-fails" (run* q (mino (list) q)) (list))

(mk-test
  "maxo-singleton"
  (run* q (maxo (list 7) q))
  (list 7))
(mk-test
  "maxo-of-5"
  (run*
    q
    (maxo (list 5 1 3 2 4) q))
  (list 5))
(mk-test
  "maxo-of-negs"
  (run* q (maxo (list -5 -1 -3) q))
  (list -1))

(mk-test
  "min-and-max-of-list"
  (run*
    q
    (fresh
      (mn mx)
      (mino (list 5 1 3 2 4) mn)
      (maxo (list 5 1 3 2 4) mx)
      (== q (list mn mx))))
  (list (list 1 5)))

(mk-tests-run!)
