(import (use 'sset)
  sset<- sset<-list sset-elements sset-insert sset-remove
  sset-union sset-difference sset-intersect)

(import ((use 'squickcheck) (export out))
  a-count a-list-of
  all should)

(let s1 (sset<- 1 7 5 3))
(let s2 (sset<- 0 2 3 4 5 9))

(out .print (sset<- 1 1 1 1))
(out .print (sset-difference s1 s2))
(out .print (sset-difference s2 s1))

(for all [(x (a-list-of a-count))]
  (let sx (sset<-list x))
  (let mx (set<-list x))
  (should = (sset-elements sx) (sort mx.keys)))

;; TODO failures won't be as easy to decipher as I'd like
(to (test-binary-ops-correspond sset-op set-op)
  (for all [(x (a-list-of a-count))
            (y (a-list-of a-count))]
    (let sx (sset<-list x)) (let sy (sset<-list y)) (let sr (sset-op sx sy))
    (let mx (set<-list x))  (let my (set<-list y))  (let mr (set-op mx my))
    (should = (sset-elements sr) (sort mr.keys))))

(test-binary-ops-correspond sset-union (on (x y) (x .union y)))
(test-binary-ops-correspond sset-intersect (on (x y) (x .intersect y)))
(test-binary-ops-correspond sset-difference (on (x y) (x .difference y)))
