diff --git a/project.clj b/project.clj index 382e146..5654245 100644 --- a/project.clj +++ b/project.clj @@ -3,4 +3,5 @@ :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.clojure/clojure "1.5.1"]]) + :dependencies [[org.clojure/clojure "1.5.1"] + [org.clojure/math.combinatorics "0.0.7"]]) diff --git a/src/testgen/core.clj b/src/testgen/core.clj index 809409c..aa35b74 100644 --- a/src/testgen/core.clj +++ b/src/testgen/core.clj @@ -23,7 +23,7 @@ (vector? arg) (map? arg)))) -(def generic-args '(nil () (quote (a :b "c")) true "test" :test 0 Integer/MAX_VALUE 22/7 0.0001 -0.0001)) +(def generic-args '(nil () (quote (a :b "c")) true "test" :test 0 22/7 0.0001 -0.0001)) (defn constants [form] "return a list of all elements in this form which are constants" @@ -40,13 +40,22 @@ true %) (constants sexpr))))) + +(defn n-of [arg n] + "Return a list of n instances of arg" + (cond + (zero? n) nil + true (cons arg (n-of arg (dec n))))) + + (defn generate-test [fndef extra-vars] (cond (or (= (first fndef) 'def)(= (first fndef) 'defn)) - (let [name (first (rest fndef))] + (let [name (first (rest fndef)) + potential-args (find-interesting-args fndef extra-vars)] (list 'deftest (symbol (str "test-" name)) (concat (list 'testing (str name)) (map #(generate-assertion name %) - (find-interesting-args fndef extra-vars))))))) + (cond (= )))))) ;; generating a test file