File: repl.clj

package info (click to toggle)
clojure1.2 1.2.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,904 kB
  • sloc: java: 23,512; xml: 256; sh: 98; makefile: 35
file content (30 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(ns clojure.test-clojure.repl
  (:use clojure.test
        clojure.repl
        clojure.test-clojure.repl.example))

(deftest test-source
  (is (= "(defn foo [])" (source-fn 'clojure.test-clojure.repl.example/foo)))
  (is (= "(defn foo [])\n" (with-out-str (source clojure.test-clojure.repl.example/foo))))
  (is (nil? (source-fn 'non-existent-fn))))

(deftest test-dir
  (is (thrown? Exception (dir-fn 'non-existent-ns)))
  (is (= '[bar foo] (dir-fn 'clojure.test-clojure.repl.example)))
  (is (= "bar\nfoo\n" (with-out-str (dir clojure.test-clojure.repl.example)))))

(deftest test-apropos
  (testing "with a regular expression"
    (is (= '[defmacro] (apropos #"^defmacro$")))
    (is (some #{'defmacro} (apropos #"def.acr.")))
    (is (= [] (apropos #"nothing-has-this-name"))))

  (testing "with a string"
    (is (some #{'defmacro} (apropos "defmacro")))
    (is (some #{'defmacro} (apropos "efmac")))
    (is (= [] (apropos "nothing-has-this-name"))))

  (testing "with a symbol"
    (is (some #{'defmacro} (apropos 'defmacro)))
    (is (some #{'defmacro} (apropos 'efmac)))
    (is (= [] (apropos 'nothing-has-this-name)))))