Permalink
Browse files

Removed some unlikely rules

  • Loading branch information...
jonase committed Jan 26, 2013
1 parent ea1e032 commit 7eb98f19eaa7881b7126715fca0caf43d89362cf
View
@@ -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]))
@@ -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
@@ -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)]
@@ -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)])
@@ -1,6 +0,0 @@
-(ns kibit.rules.performance
- (:use [kibit.rules.util :only [defrules]]))
-
-(defrules rules
- ;; reduce on var-arg functions
- [(reduce + ?coll) (apply + ?coll)])
@@ -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)))))
@@ -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))
View
@@ -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)))))
@@ -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)))
+
@@ -1,8 +0,0 @@
-(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 7eb98f1

Please sign in to comment.