From 7e173e99d0dc99902ede8c5797b82f1f7a94d041 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Sun, 6 Apr 2014 18:37:14 +0100 Subject: [PATCH] It still only works for one-arg functions, but... (also there is a problem with flushing the output file) --- src/testgen/core.clj | 6 ++++- test/testgen/core_test.clj | 55 +++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/testgen/core.clj b/src/testgen/core.clj index 11aed05..d83a492 100644 --- a/src/testgen/core.clj +++ b/src/testgen/core.clj @@ -111,6 +111,10 @@ (cond (= (first form) 'defn) (do (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))) diff --git a/test/testgen/core_test.clj b/test/testgen/core_test.clj index 69348e9..4ae3879 100644 --- a/test/testgen/core_test.clj +++ b/test/testgen/core_test.clj @@ -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")) (is (= (maybe-quote true) ''true)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-write-test (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 generic-args))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-constant? (testing @@ -74,6 +82,10 @@ (is (= (constant? 1.0E-4) 'true)) (is (= (constant? -1.0E-4) 'true)) (is (= (constant? generic-args) 'false)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-constants (testing @@ -98,6 +110,10 @@ (constants "return a list of all elements in this form which are constants") '())))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-find-interesting-args (testing @@ -163,6 +179,10 @@ (thrown? clojure.lang.ArityException (find-interesting-args 0.0))) (is (thrown? clojure.lang.ArityException (find-interesting-args true))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-testgen (testing @@ -181,6 +201,10 @@ (is (thrown? clojure.lang.ArityException (testgen -1.0E-4))) (is (thrown? clojure.lang.ArityException (testgen generic-args))) (is (thrown? clojure.lang.ArityException (testgen "test-"))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-clean-filename (testing @@ -238,6 +262,10 @@ (is (thrown? java.lang.IllegalArgumentException (clean-filename 3))) (is (thrown? java.lang.IllegalArgumentException (clean-filename true))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-test-filename (testing @@ -287,6 +315,10 @@ (is (= (test-filename "") '"test/_test.clj")) (is (= (test-filename "test/") '"test/test/_test.clj")) (is (= (test-filename "_test.clj") '"test/_test_test.clj")))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-packagename-from-filename (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."))) (is (= (packagename-from-filename "/") (symbol "."))) (is (= (packagename-from-filename ".") (symbol "."))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-find-vars-in-reader (testing @@ -362,6 +398,10 @@ (is (= (find-vars-in-reader generic-args) 'nil)) (is (= (find-vars-in-reader nil) 'nil)) (is (= (find-vars-in-reader true) 'nil)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-find-vars-in-file (testing @@ -408,6 +448,10 @@ (thrown? java.lang.IllegalArgumentException (find-vars-in-file generic-args))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (deftest test-generate-tests (testing @@ -444,4 +488,13 @@ ";; auto-generated by testgen - see https://github.com/simon-brooke/testgen\n\n") '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)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +