-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from duelinmarkers/test-coverage-for-rules
Test coverage for rules
- Loading branch information
Showing
6 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |