Half way towards getting multiple args working (don't work yet)

This commit is contained in:
Simon Brooke 2014-04-08 18:05:59 +01:00
parent 1e2c8852d4
commit f9325526ab
2 changed files with 14 additions and 4 deletions

View file

@ -3,4 +3,5 @@
:url "http://example.com/FIXME" :url "http://example.com/FIXME"
:license {:name "Eclipse Public License" :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"} :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"]])

View file

@ -23,7 +23,7 @@
(vector? arg) (vector? arg)
(map? 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] (defn constants [form]
"return a list of all elements in this form which are constants" "return a list of all elements in this form which are constants"
@ -40,13 +40,22 @@
true %) true %)
(constants sexpr))))) (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] (defn generate-test [fndef extra-vars]
(cond (or (= (first fndef) 'def)(= (first fndef) 'defn)) (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)) (list 'deftest (symbol (str "test-" name))
(concat (list 'testing (str name)) (concat (list 'testing (str name))
(map #(generate-assertion name %) (map #(generate-assertion name %)
(find-interesting-args fndef extra-vars))))))) (cond (= ))))))
;; generating a test file ;; generating a test file