;; lib/minikanren/tests/flat-mapo.sx — concatMap-style relation.

(mk-test
  "flat-mapo-empty"
  (run* q (flat-mapo (fn (x r) (== r (list x x))) (list) q))
  (list (list)))

(mk-test
  "flat-mapo-duplicate-each"
  (run*
    q
    (flat-mapo
      (fn (x r) (== r (list x x)))
      (list 1 2 3)
      q))
  (list
    (list 1 1 2 2 3 3)))

(mk-test
  "flat-mapo-empty-from-each"
  (run* q (flat-mapo (fn (x r) (== r (list))) (list :a :b :c) q))
  (list (list)))

(mk-test
  "flat-mapo-singleton-from-each-is-identity"
  (run* q (flat-mapo (fn (x r) (== r (list x))) (list :a :b :c) q))
  (list (list :a :b :c)))

(mk-test
  "flat-mapo-tag-each"
  (run*
    q
    (flat-mapo
      (fn (x r) (== r (list :tag x)))
      (list 1 2)
      q))
  (list (list :tag 1 :tag 2)))

(mk-tests-run!)
