;; lib/minikanren/tests/lasto.sx — last-element + init-without-last.

(mk-test
  "lasto-singleton"
  (run* q (lasto (list 5) q))
  (list 5))
(mk-test
  "lasto-multi"
  (run* q (lasto (list 1 2 3 4) q))
  (list 4))
(mk-test "lasto-empty" (run* q (lasto (list) q)) (list))

(mk-test "lasto-strings" (run* q (lasto (list "a" "b" "c") q)) (list "c"))

(mk-test
  "init-o-multi"
  (run* q (init-o (list 1 2 3 4) q))
  (list (list 1 2 3)))

(mk-test
  "init-o-singleton"
  (run* q (init-o (list 7) q))
  (list (list)))

(mk-test "init-o-empty" (run* q (init-o (list) q)) (list))

(mk-test
  "lasto-init-o-roundtrip"
  (run*
    q
    (fresh
      (init last)
      (lasto (list 1 2 3 4) last)
      (init-o (list 1 2 3 4) init)
      (appendo init (list last) q)))
  (list (list 1 2 3 4)))

(mk-tests-run!)
