;; lib/minikanren/tests/prefix-suffix.sx — appendo-derived sublist relations.

(mk-test
  "prefixo-empty"
  (run* q (prefixo (list) (list 1 2 3)))
  (list (make-symbol "_.0")))

(mk-test
  "prefixo-full"
  (run*
    q
    (prefixo
      (list 1 2 3)
      (list 1 2 3)))
  (list (make-symbol "_.0")))

(mk-test
  "prefixo-partial"
  (run*
    q
    (prefixo
      (list 1 2)
      (list 1 2 3 4)))
  (list (make-symbol "_.0")))

(mk-test
  "prefixo-mismatch-fails"
  (run*
    q
    (prefixo
      (list 1 3)
      (list 1 2 3)))
  (list))

(mk-test
  "prefixo-enumerates-all"
  (run* q (prefixo q (list 1 2 3)))
  (list
    (list)
    (list 1)
    (list 1 2)
    (list 1 2 3)))

(mk-test
  "suffixo-empty"
  (run* q (suffixo (list) (list 1 2 3)))
  (list (make-symbol "_.0")))

(mk-test
  "suffixo-full"
  (run*
    q
    (suffixo
      (list 1 2 3)
      (list 1 2 3)))
  (list (make-symbol "_.0")))

(mk-test
  "suffixo-partial"
  (run*
    q
    (suffixo
      (list 2 3)
      (list 1 2 3)))
  (list (make-symbol "_.0")))

(mk-test
  "suffixo-enumerates-all"
  (run* q (suffixo q (list 1 2 3)))
  (list
    (list 1 2 3)
    (list 2 3)
    (list 3)
    (list)))

(mk-tests-run!)
