;; lib/minikanren/tests/swap-firsto.sx — swap first two elements.

(mk-test
  "swap-firsto-pair"
  (run* q (swap-firsto (list 1 2) q))
  (list (list 2 1)))

(mk-test
  "swap-firsto-with-tail"
  (run* q (swap-firsto (list 1 2 3 4) q))
  (list (list 2 1 3 4)))

(mk-test
  "swap-firsto-singleton-fails"
  (run* q (swap-firsto (list 1) q))
  (list))

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

(mk-test
  "swap-firsto-self-inverse"
  (run*
    q
    (fresh (mid) (swap-firsto (list :a :b :c :d) mid) (swap-firsto mid q)))
  (list (list :a :b :c :d)))

(mk-test
  "swap-firsto-backward"
  (run* q (swap-firsto q (list :y :x :z)))
  (list (list :x :y :z)))

(mk-tests-run!)
