Mercurial > lasercutter
annotate 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 |
rev | line source |
---|---|
rlm@10 | 1 (ns clojure.test-clojure.repl |
rlm@10 | 2 (:use clojure.test |
rlm@10 | 3 clojure.repl |
rlm@10 | 4 clojure.test-clojure.repl.example)) |
rlm@10 | 5 |
rlm@10 | 6 (deftest test-source |
rlm@10 | 7 (is (= "(defn foo [])" (source-fn 'clojure.test-clojure.repl.example/foo))) |
rlm@10 | 8 (is (= "(defn foo [])\n" (with-out-str (source clojure.test-clojure.repl.example/foo)))) |
rlm@10 | 9 (is (nil? (source-fn 'non-existent-fn)))) |
rlm@10 | 10 |
rlm@10 | 11 (deftest test-dir |
rlm@10 | 12 (is (thrown? Exception (dir-fn 'non-existent-ns))) |
rlm@10 | 13 (is (= '[bar foo] (dir-fn 'clojure.test-clojure.repl.example))) |
rlm@10 | 14 (is (= "bar\nfoo\n" (with-out-str (dir clojure.test-clojure.repl.example))))) |
rlm@10 | 15 |
rlm@10 | 16 (deftest test-apropos |
rlm@10 | 17 (testing "with a regular expression" |
rlm@10 | 18 (is (= '[defmacro] (apropos #"^defmacro$"))) |
rlm@10 | 19 (is (some #{'defmacro} (apropos #"def.acr."))) |
rlm@10 | 20 (is (= [] (apropos #"nothing-has-this-name")))) |
rlm@10 | 21 |
rlm@10 | 22 (testing "with a string" |
rlm@10 | 23 (is (some #{'defmacro} (apropos "defmacro"))) |
rlm@10 | 24 (is (some #{'defmacro} (apropos "efmac"))) |
rlm@10 | 25 (is (= [] (apropos "nothing-has-this-name")))) |
rlm@10 | 26 |
rlm@10 | 27 (testing "with a symbol" |
rlm@10 | 28 (is (some #{'defmacro} (apropos 'defmacro))) |
rlm@10 | 29 (is (some #{'defmacro} (apropos 'efmac))) |
rlm@10 | 30 (is (= [] (apropos 'nothing-has-this-name))))) |