Permalink
Browse files

Add minimal test coverage for all rules

  • Loading branch information...
1 parent 3b5cac7 commit d7dc246e999caa40fbe1cbccfdef9ef21bb7c93b @duelinmarkers duelinmarkers committed Jun 11, 2012
@@ -0,0 +1,12 @@
+(ns kibit.test.arithmetic
+ (:require [kibit.check :as kibit])
+ (:use [clojure.test]))
+
+(deftest arithmetic-are
+ (are [expected-alt-form test-form]
+ (= expected-alt-form (:alt (kibit/check-expr test-form)))
+ '(inc num) '(+ num 1)
+ '(inc num) '(+ 1 num)
+ '(dec num) '(- num 1)
+ '(* x y z) '(* x (* y z))
+ '(+ x y z) '(+ x (+ y z))))
@@ -0,0 +1,11 @@
+(ns kibit.test.collections
+ (:require [kibit.check :as kibit])
+ (:use [clojure.test]))
+
+(deftest collections-are
+ (are [expected-alt-form test-form]
+ (= expected-alt-form (:alt (kibit/check-expr test-form)))
+ '(vector a) '(conj [] a)
+ '(vector a b) '(conj [] a b)
+ '(vec coll) '(into [] coll)
+ '(set coll) '(into #{} coll)))
@@ -2,16 +2,8 @@
(:require [kibit.check :as kibit])
(:use [clojure.test]))
-;; ==========
-;; NOTE
-;; ==============
-;; YOU SHOULD ALWAYS CHECK WITH ALL RULES
-;;
-;; Please ensure that new rules generate fully expected results across all
-;; rule sets.
-
(deftest control-structures-are
- (are [expected-alt-form test-form]
+ (are [expected-alt-form test-form]
(= expected-alt-form (:alt (kibit/check-expr test-form)))
'(when test then) '(if test then nil)
'(when-not test else) '(if test nil else)
@@ -0,0 +1,19 @@
+(ns kibit.test.equality
+ (:require [kibit.check :as kibit])
+ (:use [clojure.test]))
+
+(deftest equality-are
+ (are [expected-alt-form test-form]
+ (= expected-alt-form (:alt (kibit/check-expr test-form)))
+ '(not= x b) '(not (= x b))
+ '(zero? x) '(= 0 x)
+ '(zero? x) '(= x 0)
+ '(zero? x) '(== 0 x)
+ '(zero? x) '(== x 0)
+ '(pos? x) '(< 0 x)
+ '(pos? x) '(> x 0)
+ '(pos? x) '(<= 1 x)
+ '(neg? x) '(< x 0)
+ true '(= x x)
+ true '(== x x)
+ true '(zero? 0)))
@@ -0,0 +1,29 @@
+(ns kibit.test.misc
+ (:require [kibit.check :as kibit])
+ (:use [clojure.test]))
+
+(deftest misc-are
+ (are [expected-alt-form test-form]
+ (= expected-alt-form (:alt (kibit/check-expr test-form)))
+ '(clojure.string/join x y) '(apply str (interpose x y))
+ '(clojure.string/reverse x) '(apply str (reverse x))
+ '(mapcat x y) '(apply concat (apply map x y))
+ '(mapcat x y) '(apply concat (map x y))
+ '(remove pred coll) '(filter (complement pred) coll)
+ ;'(remove pred coll) '(filter #(not (pred %)) coll) -- Expanded form of anonymous fn literal not matching.
+ '(ffirst coll) '(first (first coll))
+ '(fnext coll) '(first (next coll))
+ '(nnext coll) '(next (next coll))
+ '(nfirst coll) '(next (first coll))
+ 'fun '(fn [args] (fun args))
+ 'fun '(fn* [args] (fun args))
+ '(str x) '(.toString x)
+ '(.method obj args) '(. obj method args)
+ '(Klass/staticMethod args) '(. Klass staticMethod args)
+ '(form arg) '(-> arg form)
+ '(:form arg) '(-> arg :form)
+ '(first-of-form arg rest-of-form) '(-> arg (first-of-form rest-of-form))
+ '(form arg) '(->> arg form)
+ '(:form arg) '(->> arg :form)
+ '(first-of-form rest-of-form arg) '(->> arg (first-of-form rest-of-form))
+ '(not-any? pred coll) '(not (some pred coll))))
@@ -0,0 +1,8 @@
+(ns kibit.test.performance
+ (:require [kibit.check :as kibit])
+ (:use [clojure.test]))
+
+(deftest performance-are
+ (are [expected-alt-form test-form]
+ (= expected-alt-form (:alt (kibit/check-expr test-form)))
+ '(apply + coll) '(reduce + coll)))

0 comments on commit d7dc246

Please sign in to comment.