Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/clj/cider/nrepl/middleware/apropos_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(is (= (var-doc #'public-var) "Test1. Test2. Test3."))
(is (= (var-doc 1 #'public-var) "Test1.")))

(deftest test-namespaces
(deftest namespaces-test
(let [ns (-> *ns* ns-name str)]
(testing "Namespace sort order"
(is (= (-> (namespaces ns nil) first ns-name str)
Expand All @@ -32,7 +32,7 @@
(is (not-any? #(re-find #".*nrepl" (str (ns-name %)))
(namespaces nil nil [".*nrepl"]))))))

(deftest test-search
(deftest search-test
(testing "Search results"
(is (empty? (find-symbols nil "xxxxxxxx" nil false false false nil))
"Failing searches should return empty.")
Expand Down
2 changes: 1 addition & 1 deletion test/clj/cider/nrepl/middleware/classpath_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(is (every? string? classpaths))
(is (some #(re-find #".*clojure-.*jar" %) classpaths))))

(deftest error-handling
(deftest error-handling-test
(with-redefs [cp/classpath (fn [] (throw (Exception. "cp error")))]
(let [response (session/message {:op "classpath"})]
(is (= (:status response) #{"done" "classpath-error"}))
Expand Down
4 changes: 2 additions & 2 deletions test/clj/cider/nrepl/middleware/complete_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(is (= '("[name & opts+sigs]") (:arglists candidate)))
(is (string? (:doc candidate))))))

(deftest complete-doc
(deftest complete-doc-test
(testing "blank"
(let [response (session/message {:op "complete-doc" :symbol ""})]
(is (= #{"done"} (:status response)))
Expand All @@ -67,7 +67,7 @@
(is (= (:status response) #{"done"}))
(is (.startsWith (:completion-doc response) "clojure.core/true?\n([x")))))

(deftest error-handling
(deftest error-handling-test
(testing "complete op error handling"
(with-redefs [c/complete (fn [& _] (throw (Exception. "complete-exc")))]
(let [response (session/message {:op "complete" :ns "doesn't matter" :symbol "fake"})]
Expand Down
22 changes: 11 additions & 11 deletions test/clj/cider/nrepl/middleware/debug_integration_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
(f)))))


(deftest debug-expression
(deftest debug-expression-test
(testing "normal eval (no debugging)"
(--> :eval "(+ 2 3)")
(<-- {:value "5"})
Expand All @@ -155,7 +155,7 @@
(<-- {:value "2"}) ; (let ...)
(<-- {:status ["done"]})))

(deftest debug-ops
(deftest debug-ops-test
(--> :eval "(ns user.test.debug)")
(<-- {:ns "user.test.debug"})
(<-- {:status ["done"]})
Expand Down Expand Up @@ -217,7 +217,7 @@
(<-- {:value "8"})
(<-- {:status ["done"]})))

(deftest call-instrumented-fn-when-stepping-out
(deftest call-instrumented-fn-when-stepping-out-test
;; When we step out of a form, instrumented functions that are
;; called should still be debugged.

Expand Down Expand Up @@ -259,7 +259,7 @@
(<-- {:value "10"})
(<-- {:status ["done"]}))

(deftest call-instrumented-fn-when-doing-here-op
(deftest call-instrumented-fn-when-doing-here-op-test
;; When we jump ahead by doing a `:here`, instrumented functions
;; that are called from the skipped-over code should still be
;; debugged.
Expand Down Expand Up @@ -307,7 +307,7 @@

;;; Tests for force-step operations

(deftest force-step-out-past-instrumented-fn
(deftest force-step-out-past-instrumented-fn-test
;; When we force-step out of a form, instrumented functions that are
;; called should not be debugged.

Expand Down Expand Up @@ -345,7 +345,7 @@
(<-- {:value "14"})
(<-- {:status ["done"]}))

(deftest force-here-past-instrumented-fn
(deftest force-here-past-instrumented-fn-test
;; When we do force-here operation that jumps past a call to an
;; instrumented function, the function should not be debugged.

Expand Down Expand Up @@ -385,7 +385,7 @@

;;; Tests for conditional breakpoints

(deftest conditional-in-for
(deftest conditional-in-for-test
(--> :eval
"(for [i (range 5)]
#dbg ^{:break/when (= 2 i)}
Expand All @@ -397,7 +397,7 @@
(<-- {:value "(1 2 3 4 5)"}) ; (for ...)
(<-- {:status ["done"]}))

(deftest conditional-in-defn
(deftest conditional-in-defn-test
(--> :eval "(ns user.test.conditional-break)")
(<-- {:ns "user.test.conditional-break"})
(<-- {:status ["done"]})
Expand All @@ -421,7 +421,7 @@
(<-- {:value "(1 2 3)"})
(<-- {:status ["done"]}))

(deftest call-instrumented-fn-from-skipped-break
(deftest call-instrumented-fn-from-skipped-break-test
;; When breaks are skipped due to a false conditional, instrumented
;; functions called from withing the skipped form should still be
;; debugged.
Expand Down Expand Up @@ -468,7 +468,7 @@
(<-- {:value "(2 3)"})
(<-- {:status ["done"]}))

(deftest step-in-to-function-in-current-project
(deftest step-in-to-function-in-current-project-test
;; We use misc/as-sym just because it's a simple function that's part of the
;; current project, and we want to ensure that the debugger can find and
;; instrument the code of a function that lives in a regular file on the
Expand Down Expand Up @@ -542,7 +542,7 @@
(<-- {:value "blah"})
(<-- {:status ["done"]})))

(deftest step-in-to-function-in-jar
(deftest step-in-to-function-in-jar-test
;; Step into clojure.tools.nrepl.server/handle*. To do this, we need to find
;; and instrument the source, which is in a jar file. Note that this function
;; is used because it is not marked as a :source-dep, so we can rely on the
Expand Down
28 changes: 14 additions & 14 deletions test/clj/cider/nrepl/middleware/debug_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

(def ^:const bfkey :cider.nrepl.middleware.util.instrument/breakfunction)

(deftest irrelevant-return-value
(deftest irrelevant-return-value-test
(are [x] (let [exp (clojure.walk/macroexpand-all x)]
(= exp (clojure.walk/macroexpand-all `(d/breakpoint-if-interesting ~exp [] nil))))
'(defn name "" [] (inc 2))
Expand All @@ -16,7 +16,7 @@
'(fn name [] (inc 2))
'(fn* name ([] (inc 2)))))

(deftest coord<
(deftest coord<-test
(are [a b] (and (d/coord< a b)
(not (d/coord< b a)))
[1] []
Expand All @@ -25,7 +25,7 @@
[1 2] [1 3]
[1 0] [1]))

(deftest skip-breaks
(deftest skip-breaks-test
(binding [d/*skip-breaks* (atom {:mode :all})]
(is (#'d/skip-breaks? []))
(is (#'d/skip-breaks? nil))
Expand Down Expand Up @@ -92,7 +92,7 @@
(with-redefs [t/send (send-override :inject)]
(is (= :inject (#'d/read-debug-command 'value {})))))

(deftest read-debug-command-eval
(deftest read-debug-command-eval-test
(let [replies (atom [:eval 100 :next])]
(with-redefs [t/send (fn [trans {:keys [key]}]
(deliver (@d/promises key) (first @replies))
Expand All @@ -106,7 +106,7 @@
`(binding [d/*locals* ~(#'d/sanitize-env &env)]
~value))

(deftest read-debug-eval-expression
(deftest read-debug-eval-expression-test
(reset! d/debugger-message {})
(let [x 1]
(with-redefs [t/send (send-override '(inc 10))]
Expand All @@ -122,7 +122,7 @@
(with-locals
(#'d/eval-with-locals '(inc x)))))))

(deftest eval-with-locals-exceptions
(deftest eval-with-locals-exceptions-test
(binding [*msg* {:session (atom {})}]
(let [e (Exception. "HI")
resp (atom nil)]
Expand All @@ -132,7 +132,7 @@
(is (coll? (:causes @resp)))
(is (= "HI" (:message (last (:causes @resp)))))))))

(deftest initialize
(deftest initialize-test
(with-redefs [d/debugger-message (atom nil)]
(let [resp (atom nil)]
(with-redefs [t/send (fn [_ response] (reset! resp response))]
Expand All @@ -144,15 +144,15 @@
(#'d/initialize {:hi true}))
(is (:status @resp)))))

(deftest locals-for-message
(deftest locals-for-message-test
(let [x 1
to_ignore 0
to__ignore 0]
(with-locals
(is (= '(("x" "1"))
(#'d/locals-for-message d/*locals*))))))

(deftest eval-expression-with-code
(deftest eval-expression-with-code-test
(with-locals
(is (= (#'d/read-debug-eval-expression
"Unused prompt" {:some "random", 'meaningless :map} '(inc 1))
Expand All @@ -163,37 +163,37 @@
"Unused prompt" {:some "random", 'meaningless :map} '(inc x))
11)))))

(deftest inspect-then-read-command
(deftest inspect-then-read-command-test
(with-redefs [d/debugger-message (atom {:session (atom {})})
d/read-debug-command vector]
(let [[v m] (#'d/inspect-then-read-command :value {} 32 10)]
(is (= v :value))
(is (string? (:inspect m))))))

(deftest debug-reader
(deftest debug-reader-test
(is (empty? (remove #(bfkey (meta %))
(d/debug-reader '[a b c]))))
(is (bfkey (meta (d/debug-reader '[a b c]))))
(is (= (count (remove #(bfkey (meta %))
(d/debug-reader '[a :b 10])))
2)))

(deftest breakpoint-reader
(deftest breakpoint-reader-test
(is (bfkey (meta (d/breakpoint-reader '[a b c]))))
(is (= '[a :b 10 "ok"]
(remove #(bfkey (meta %)) (d/breakpoint-reader '[a :b 10 "ok"]))))
;; Just don't error
(is (map d/breakpoint-reader '[a :b 10 "ok"])))

(deftest reader-macros
(deftest reader-macros-test
(binding [*data-readers* {'dbg d/debug-reader}]
;; Reader macro variants
(is (empty? (remove #(bfkey (meta %)) (read-string "#dbg [a b c]"))))
(is (bfkey (meta (read-string "#dbg [a b c]"))))
(is (= (count (remove #(bfkey (meta %)) (read-string "#dbg [a :b 10]")))
2))))

(deftest pr-short
(deftest pr-short-test
(reset! d/print-length 4)
(reset! d/print-level 2)
(is (< (count (d/pr-short [1 2 3 4 5 6 7 8 9 10]))
Expand Down
4 changes: 2 additions & 2 deletions test/clj/cider/nrepl/middleware/format_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

(use-fixtures :once session/session-fixture)

(deftest test-format-code-op
(deftest format-code-op-test
(testing "format-code works"
(let [{:keys [formatted-code status]} (session/message {:op "format-code"
:code ugly-code-sample})]
Expand All @@ -66,7 +66,7 @@
(is (.startsWith err "clojure.lang.ExceptionInfo: Invalid"))
(is (= ex "class clojure.lang.ExceptionInfo")))))

(deftest test-format-edn-op
(deftest format-edn-op-test
(testing "format-edn works"
(let [{:keys [formatted-edn status]} (session/message {:op "format-edn"
:edn ugly-edn-sample})]
Expand Down
24 changes: 12 additions & 12 deletions test/clj/cider/nrepl/middleware/info_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[x]
(:resource (info/file-info x)))

(deftest test-javadoc-url
(deftest javadoc-url-test
(testing "java 1.7"
(is (= "http://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html#charAt(int)"
(with-redefs [util/java-api-version "7"]
Expand All @@ -33,7 +33,7 @@
(info/format-response)
(get "javadoc")))))))

(deftest test-resource-path
(deftest resource-path-test
(is (= (class (file (subs (str (clojure.java.io/resource "clojure/core.clj")) 4)))
java.net.URL))
(is (= (class (file "clojure/core.clj"))
Expand All @@ -46,7 +46,7 @@
(is (nil? (relative "notclojure/core.clj")))
(is (nil? (info/resource-path "jar:file:fake.jar!/fake/file.clj"))))

(deftest test-boot-resource-path
(deftest boot-resource-path-test
(let [tmp-dir-name (System/getProperty "java.io.tmpdir")
tmp-file-name "boot-test.txt"
tmp-file-path (str tmp-dir-name (System/getProperty "file.separator") tmp-file-name)]
Expand Down Expand Up @@ -75,7 +75,7 @@

(deftype T [])

(deftest test-info
(deftest info-test
(is (info/info-clj 'cider.nrepl.middleware.info 'io))

(is (info/info-clj 'cider.nrepl.middleware.info 'info-clj))
Expand Down Expand Up @@ -126,7 +126,7 @@

;; test CLJX resolve
(is (= "simple/test/workaround.cljx"
(-> (info/info-clj 'cider.nrepl.middleware.info-test 'test-info)
(-> (info/info-clj 'cider.nrepl.middleware.info-test 'info-test)
info/handle-cljx-sources
:file)))

Expand All @@ -138,7 +138,7 @@
;; this is a replacement for (is (not (thrown? ..)))
(is (nil? (info/info {:class "Thread" :member "UncaughtExceptionHandler"}))))

(deftest test-response
(deftest response-test
(let [v (ns-resolve 'cider.nrepl.middleware.info 'assoc)
{:keys [arglists column line added static doc]} (meta v)]
(is (= (dissoc (info/format-response (info/info-clj 'cider.nrepl.middleware.info 'assoc)) "file")
Expand Down Expand Up @@ -176,7 +176,7 @@
[Classname/staticMethod args*]
[Classname/staticField]))))

(deftest test-format-arglists
(deftest format-arglists-test
(is (= (info/format-arglists (info/extract-arglists test-eldoc-info)) '(["x"] ["x" "y"])))
(is (= (info/format-arglists (info/extract-arglists test-eldoc-info-candidates))
'([] ["x"] ["x" "y" "z"]))))
Expand All @@ -187,7 +187,7 @@
(is (info/extract-arglists (info/info {:ns "clojure.core" :symbol "."})))
(is (not (info/extract-arglists (info/info {:ns "clojure.core" :symbol (gensym "non-existing")})))))

(deftest test-var-meta
(deftest var-meta-test
;; Test files can't be found on the class path.
(is (:file (info/var-meta #'info/var-meta)))
(is (re-find #"cider-nrepl" (:file (#'info/maybe-add-file {:ns (find-ns 'cider.nrepl.middleware.info)}))))
Expand Down Expand Up @@ -248,7 +248,7 @@
`(if (not ~pred) ~a ~b))

(use-fixtures :each session/session-fixture)
(deftest integration-tests
(deftest integration-test
(testing "info op"
(testing "get info of a clojure function"
(let [response (session/message {:op "info" :symbol "testing-function" :ns "cider.nrepl.middleware.info-test"})]
Expand Down Expand Up @@ -471,7 +471,7 @@
(set (:eldoc response))))
(is (= (:type response) "function"))))))

(deftest missing-info
(deftest missing-info-test
(testing "ensure info returns a no-info packet if symbol not found"
(let [response (session/message {:op "info" :symbol "awoeijfxcvb" :ns "user"})]
(is (= (:status response) #{"no-info" "done"}))))
Expand All @@ -488,7 +488,7 @@
(let [response (session/message {:op "info" :class "java.lang.Exception" :member "fakefakefake"})]
(is (= (:status response) #{"no-info" "done"})))))

(deftest missing-eldoc
(deftest missing-eldoc-test
(testing "ensure eldoc returns a no-eldoc packet if symbol not found"
(let [response (session/message {:op "eldoc" :symbol "awoeijfxcvb" :ns "user"})]
(is (= (:status response) #{"no-eldoc" "done"}))))
Expand All @@ -505,7 +505,7 @@
(let [response (session/message {:op "eldoc" :class "java.lang.Exception" :member "fakefakefake"})]
(is (= (:status response) #{"no-eldoc" "done"})))))

(deftest error-handling
(deftest error-handling-test
(testing "handle the exception thrown if no member provided to a java class info query"
(let [response (session/message {:op "info" :class "test"})]
(is (= (:status response) #{"info-error" "done"}))
Expand Down
Loading