Skip to content

Commit

Permalink
Add tests for clj-commons#78
Browse files Browse the repository at this point in the history
  • Loading branch information
arrdem committed May 9, 2017
1 parent 14c10ee commit 68729aa
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions kibit/test/kibit/test/collections.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,33 @@

(deftest collections-are
(are [expected-alt-form test-form]
(= expected-alt-form (:alt (kibit/check-expr test-form)))
'(seq a) '(not (empty? a))
'(when (seq a) b) '(when-not (empty? a) b)
'(when (seq a) b) '(when (not (empty? a)) b)
'(vector a) '(conj [] a)
'(vector a b) '(conj [] a b)
'(vec coll) '(into [] coll)
'(set coll) '(into #{} coll)
'(update-in coll [k] f) '(assoc coll k (f (k coll)))
'(update-in coll [k] f) '(assoc coll k (f (coll k)))
'(update-in coll [k] f) '(assoc coll k (f (get coll k)))
'(assoc-in coll [k0 k1] a) '(assoc coll k0 (assoc (k0 coll) k1 a))
'(assoc-in coll [k0 k1] a) '(assoc coll k0 (assoc (coll k0) k1 a))
'(assoc-in coll [k0 k1] a) '(assoc coll k0 (assoc (get coll k0) k1 a))
'(update-in coll [k] f a b c) '(assoc coll k (f (k coll) a b c))
'(update-in coll [k] f a b c) '(assoc coll k (f (coll k) a b c))
'(update-in coll [k] f a b c) '(assoc coll k (f (get coll k) a b c))
'(assoc-in coll [k1 k2] v) '(update-in coll [k1 k2] assoc v)
(= expected-alt-form (:alt (kibit/check-expr test-form)))
'(seq a) '(not (empty? a))
'(when (seq a) b) '(when-not (empty? a) b)
'(when (seq a) b) '(when (not (empty? a)) b)
'(vector a) '(conj [] a)
'(vector a b) '(conj [] a b)
'(vec coll) '(into [] coll)
'(set coll) '(into #{} coll)
'(update-in coll [k] f) '(assoc coll k (f (k coll)))
'(update-in coll [k] f) '(assoc coll k (f (coll k)))
'(update-in coll [k] f) '(assoc coll k (f (get coll k)))
'(assoc-in coll [k0 k1] a) '(assoc coll k0 (assoc (k0 coll) k1 a))
'(assoc-in coll [k0 k1] a) '(assoc coll k0 (assoc (coll k0) k1 a))
'(assoc-in coll [k0 k1] a) '(assoc coll k0 (assoc (get coll k0) k1 a))
'(update-in coll [k] f a b c) '(assoc coll k (f (k coll) a b c))
'(update-in coll [k] f a b c) '(assoc coll k (f (coll k) a b c))
'(update-in coll [k] f a b c) '(assoc coll k (f (get coll k) a b c))
'(assoc-in coll [k1 k2] v) '(update-in coll [k1 k2] assoc v)
'(repeatedly 10 (constantly :foo)) '(take 10 (repeatedly (constantly :foo)))
'(run! f coll) '(dorun (map f coll))
'(run! f coll) '(dorun (map f coll))

;; some wrong simplifications happened in the past:
nil '(assoc coll k (assoc (coll k0) k1 a))
nil '(assoc coll k (assoc (get coll k0) k1 a))
nil '(assoc coll k (assoc (k0 coll) k1 a))))
nil '(assoc coll k (assoc (k0 coll) k1 a))
nil '#{#{}
#{#{}}
#{#{#{}}}
#{#{#{#{}}}}
#{#{#{#{#{}}}}}}))

0 comments on commit 68729aa

Please sign in to comment.