diff src/clojure/test_clojure/repl.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/test_clojure/repl.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,30 @@
     1.4 +(ns clojure.test-clojure.repl
     1.5 +  (:use clojure.test
     1.6 +        clojure.repl
     1.7 +        clojure.test-clojure.repl.example))
     1.8 +
     1.9 +(deftest test-source
    1.10 +  (is (= "(defn foo [])" (source-fn 'clojure.test-clojure.repl.example/foo)))
    1.11 +  (is (= "(defn foo [])\n" (with-out-str (source clojure.test-clojure.repl.example/foo))))
    1.12 +  (is (nil? (source-fn 'non-existent-fn))))
    1.13 +
    1.14 +(deftest test-dir
    1.15 +  (is (thrown? Exception (dir-fn 'non-existent-ns)))
    1.16 +  (is (= '[bar foo] (dir-fn 'clojure.test-clojure.repl.example)))
    1.17 +  (is (= "bar\nfoo\n" (with-out-str (dir clojure.test-clojure.repl.example)))))
    1.18 +
    1.19 +(deftest test-apropos
    1.20 +  (testing "with a regular expression"
    1.21 +    (is (= '[defmacro] (apropos #"^defmacro$")))
    1.22 +    (is (some #{'defmacro} (apropos #"def.acr.")))
    1.23 +    (is (= [] (apropos #"nothing-has-this-name"))))
    1.24 +
    1.25 +  (testing "with a string"
    1.26 +    (is (some #{'defmacro} (apropos "defmacro")))
    1.27 +    (is (some #{'defmacro} (apropos "efmac")))
    1.28 +    (is (= [] (apropos "nothing-has-this-name"))))
    1.29 +
    1.30 +  (testing "with a symbol"
    1.31 +    (is (some #{'defmacro} (apropos 'defmacro)))
    1.32 +    (is (some #{'defmacro} (apropos 'efmac)))
    1.33 +    (is (= [] (apropos 'nothing-has-this-name)))))