It still only works for one-arg functions, but...

(also there is a problem with flushing the output file)
This commit is contained in:
Simon Brooke 2014-04-06 18:37:14 +01:00
parent c969dcdd2d
commit 7e173e99d0
2 changed files with 59 additions and 2 deletions

View file

@ -111,6 +111,10 @@
(cond (= (first form) 'defn) (cond (= (first form) 'defn)
(do (do
(println (first (rest form)) "...") (println (first (rest form)) "...")
(pprint (testgen form extra-vars) dickens))))))) (pprint (testgen form extra-vars) dickens)
(.write dickens "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")
))))
(.write dickens "\n\n;; end of file ;;\n\n")
(.flush dickens)))
(catch Exception eof))) (catch Exception eof)))

View file

@ -39,6 +39,10 @@
"Convert val into a form in which, after being passed through the pretty\n\tprinter, it will be reconstituted in a form useful to the test") "Convert val into a form in which, after being passed through the pretty\n\tprinter, it will be reconstituted in a form useful to the test")
''"Convert val into a form in which, after being passed through the pretty\n\tprinter, it will be reconstituted in a form useful to the test")) ''"Convert val into a form in which, after being passed through the pretty\n\tprinter, it will be reconstituted in a form useful to the test"))
(is (= (maybe-quote true) ''true)))) (is (= (maybe-quote true) ''true))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-write-test test-write-test
(testing (testing
@ -58,6 +62,10 @@
(is (thrown? clojure.lang.ArityException (write-test 1.0E-4))) (is (thrown? clojure.lang.ArityException (write-test 1.0E-4)))
(is (thrown? clojure.lang.ArityException (write-test -1.0E-4))) (is (thrown? clojure.lang.ArityException (write-test -1.0E-4)))
(is (thrown? clojure.lang.ArityException (write-test generic-args))))) (is (thrown? clojure.lang.ArityException (write-test generic-args)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-constant? test-constant?
(testing (testing
@ -74,6 +82,10 @@
(is (= (constant? 1.0E-4) 'true)) (is (= (constant? 1.0E-4) 'true))
(is (= (constant? -1.0E-4) 'true)) (is (= (constant? -1.0E-4) 'true))
(is (= (constant? generic-args) 'false)))) (is (= (constant? generic-args) 'false))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-constants test-constants
(testing (testing
@ -98,6 +110,10 @@
(constants (constants
"return a list of all elements in this form which are constants") "return a list of all elements in this form which are constants")
'())))) '()))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-find-interesting-args test-find-interesting-args
(testing (testing
@ -163,6 +179,10 @@
(thrown? clojure.lang.ArityException (find-interesting-args 0.0))) (thrown? clojure.lang.ArityException (find-interesting-args 0.0)))
(is (is
(thrown? clojure.lang.ArityException (find-interesting-args true))))) (thrown? clojure.lang.ArityException (find-interesting-args true)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-testgen test-testgen
(testing (testing
@ -181,6 +201,10 @@
(is (thrown? clojure.lang.ArityException (testgen -1.0E-4))) (is (thrown? clojure.lang.ArityException (testgen -1.0E-4)))
(is (thrown? clojure.lang.ArityException (testgen generic-args))) (is (thrown? clojure.lang.ArityException (testgen generic-args)))
(is (thrown? clojure.lang.ArityException (testgen "test-"))))) (is (thrown? clojure.lang.ArityException (testgen "test-")))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-clean-filename test-clean-filename
(testing (testing
@ -238,6 +262,10 @@
(is (thrown? java.lang.IllegalArgumentException (clean-filename 3))) (is (thrown? java.lang.IllegalArgumentException (clean-filename 3)))
(is (is
(thrown? java.lang.IllegalArgumentException (clean-filename true))))) (thrown? java.lang.IllegalArgumentException (clean-filename true)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-test-filename test-test-filename
(testing (testing
@ -287,6 +315,10 @@
(is (= (test-filename "") '"test/_test.clj")) (is (= (test-filename "") '"test/_test.clj"))
(is (= (test-filename "test/") '"test/test/_test.clj")) (is (= (test-filename "test/") '"test/test/_test.clj"))
(is (= (test-filename "_test.clj") '"test/_test_test.clj")))) (is (= (test-filename "_test.clj") '"test/_test_test.clj"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-packagename-from-filename test-packagename-from-filename
(testing (testing
@ -344,6 +376,10 @@
"Return, as a symbol, the package name associated with this filename. There's\n probably a better way of doing this."))) "Return, as a symbol, the package name associated with this filename. There's\n probably a better way of doing this.")))
(is (= (packagename-from-filename "/") (symbol "."))) (is (= (packagename-from-filename "/") (symbol ".")))
(is (= (packagename-from-filename ".") (symbol "."))))) (is (= (packagename-from-filename ".") (symbol ".")))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-find-vars-in-reader test-find-vars-in-reader
(testing (testing
@ -362,6 +398,10 @@
(is (= (find-vars-in-reader generic-args) 'nil)) (is (= (find-vars-in-reader generic-args) 'nil))
(is (= (find-vars-in-reader nil) 'nil)) (is (= (find-vars-in-reader nil) 'nil))
(is (= (find-vars-in-reader true) 'nil)))) (is (= (find-vars-in-reader true) 'nil))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-find-vars-in-file test-find-vars-in-file
(testing (testing
@ -408,6 +448,10 @@
(thrown? (thrown?
java.lang.IllegalArgumentException java.lang.IllegalArgumentException
(find-vars-in-file generic-args))))) (find-vars-in-file generic-args)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftest (deftest
test-generate-tests test-generate-tests
(testing (testing
@ -444,4 +488,13 @@
";; auto-generated by testgen - see https://github.com/simon-brooke/testgen\n\n") ";; auto-generated by testgen - see https://github.com/simon-brooke/testgen\n\n")
'nil)) 'nil))
(is (= (generate-tests "reading...") 'nil)) (is (= (generate-tests "reading...") 'nil))
(is (= (generate-tests "...") 'nil)))) (is (= (generate-tests "...") 'nil))
(is
(=
(generate-tests "\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")
'nil))
(is (= (generate-tests "\n\n;; end of file ;;\n\n") 'nil))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;