Skip to content

Commit

Permalink
Removed some unlikely rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jonase committed Jan 26, 2013
1 parent ea1e032 commit 7eb98f1
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 48 deletions.
2 changes: 0 additions & 2 deletions src/kibit/rules.clj
Expand Up @@ -6,7 +6,6 @@
[kibit.rules.control-structures :as control]
[kibit.rules.collections :as coll]
[kibit.rules.equality :as equality]
[kibit.rules.performance :as perf]
[kibit.rules.misc :as misc]
[clojure.core.logic :as logic]))

Expand Down Expand Up @@ -34,7 +33,6 @@
:arithmetic arith/rules
:collections coll/rules
:equality equality/rules
:perf perf/rules
:misc misc/rules})

;; TODO: Consider a refactor for this into a function
Expand Down
5 changes: 0 additions & 5 deletions src/kibit/rules/control_structures.clj
Expand Up @@ -7,12 +7,7 @@
[(if ?x (do . ?y)) (when ?x . ?y)]
[(if (not ?x) ?y ?z) (if-not ?x ?y ?z)]
[(when (not ?x) . ?y) (when-not ?x . ?y)]
[(if true ?x ?y) ?x]
[(if true ?x) ?x]
[(when true . ?x) (do . ?x)]
[(do ?x) ?x]
[(when-not true ?x) _]
[(when false ?x) _]
[(if-let ?binding ?expr nil) (when-let ?binding ?expr)]
[(when ?x (do . ?y)) (when ?x . ?y)]
[(when-not ?x (do . ?y)) (when-not ?x . ?y)]
Expand Down
4 changes: 0 additions & 4 deletions src/kibit/rules/equality.clj
Expand Up @@ -17,10 +17,6 @@

[(< ?x 0) (neg? ?x)]

[(= ?x ?x) true]
[(== ?x ?x) true]
[(zero? 0) true]

; nil?
[(= ?x nil) (nil? ?x)]
[(= nil ?x) (nil? ?x)])
Expand Down
6 changes: 0 additions & 6 deletions src/kibit/rules/performance.clj

This file was deleted.

6 changes: 0 additions & 6 deletions test/kibit/test/check.clj
Expand Up @@ -21,11 +21,5 @@
'(do [1 2 3]) '(do [1 2 3])
nil '(if (> 2 3) :one :two)))

(deftest simplify-deep
(is (= :one
(:alt (kibit/check-expr '(if (= 0 0) :one nil))))))

(deftest simplify-one
(is (= '(when (= 0 0) :one)
(:alt (kibit/check-expr '(if (= 0 0) :one nil) :resolution :subform)))))

5 changes: 0 additions & 5 deletions test/kibit/test/control_structures.clj
Expand Up @@ -10,12 +10,7 @@
'(when test body) '(if test (do body))
'(if-not test then else) '(if (not test) then else)
'(when-not test then) '(when (not test) then)
'(println "X") '(if true (println "X") nil)
'(println "X") '(if true (println "X"))
'(do body-1 body-2) '(when true body-1 body-2)
'single-expression '(do single-expression)
'_ '(when-not true anything)
'_ '(when false anything)
'(when-let [a test] expr) '(if-let [a test] expr nil)
'(let [a 1] (println a) a) '(let [a 1] (do (println a) a))
'(when test (println a) then) '(when test (do (println a) then))
Expand Down
8 changes: 0 additions & 8 deletions test/kibit/test/core.clj
Expand Up @@ -24,13 +24,5 @@
'(do [1 2 3]) '(do [1 2 3])
nil '(if (> 2 3) :one :two)))

(deftest simplify-deep
(is (= :one
(core/simplify '(if (= 0 0) :one nil) all-rules)
(:alt (kibit/check-expr '(if (= 0 0) :one nil))))))

(deftest simplify-one
(is (= '(when (= 0 0) :one)
(core/simplify-one '(if (= 0 0) :one nil) all-rules)
(:alt (kibit/check-expr '(if (= 0 0) :one nil) :resolution :subform)))))

6 changes: 2 additions & 4 deletions test/kibit/test/equality.clj
Expand Up @@ -15,7 +15,5 @@
'(pos? x) '(<= 1 x)
'(neg? x) '(< x 0)
'(nil? x) '(= nil x)
'(nil? x) '(= x nil)
true '(= x x)
true '(== x x)
true '(zero? 0)))
'(nil? x) '(= x nil)))

8 changes: 0 additions & 8 deletions test/kibit/test/performance.clj

This file was deleted.

0 comments on commit 7eb98f1

Please sign in to comment.