summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVitalie Spinu <spinuvit@gmail.com>2014-09-14 23:42:41 -0700
committerVitalie Spinu <spinuvit@gmail.com>2014-09-15 20:14:27 -0700
commitd201a438218b154edd7630abb4bedc715caa7849 (patch)
treef77d4951acd5afc402056f9095d7e2252b2e51ea /test
parent0278169d03a59cd8b59521a3552bb3b111968101 (diff)
Rewrite `sync-request` subsystem
Changes to `nrepl-send-sync-request`: - returned response is now a standard nREPL dict - returned response is a merged dict of all the responses received so far Other changes: - remove macroexpand-1 macroexpand-all from cider-required-nrepl-ops - Reduce redundancy in eval APIs by removing several eval functions on CIDER side. They were either not used or could be replaced with direct calls to nrepl API. - Enforce `cider-sync-request:OP` convention and move all requests into `cider-client.el`.
Diffstat (limited to 'test')
-rw-r--r--test/cider-tests--no-auto.el11
-rw-r--r--test/cider-tests.el31
-rw-r--r--test/nrepl-bencode-tests.el25
3 files changed, 47 insertions, 20 deletions
diff --git a/test/cider-tests--no-auto.el b/test/cider-tests--no-auto.el
index fe90547d..cd543630 100644
--- a/test/cider-tests--no-auto.el
+++ b/test/cider-tests--no-auto.el
@@ -45,7 +45,8 @@ leading line of all dashes and trailing nil (when no doc is present) are removed
from the latter. Remaining content is compared for string equality."
(let ((repl-doc (with-temp-buffer
(let ((form (format "(clojure.repl/doc %s)" sym)))
- (insert (plist-get (nrepl-send-sync-request form) :stdout))
+ (insert (nrepl-dict-get (nrepl-send-sync-request form)
+ "out"))
(goto-char (point-min))
(while (re-search-forward "^ nil\n" nil t)
(replace-match ""))
@@ -69,14 +70,16 @@ from the latter. Remaining content is compared for string equality."
(defun cider-test-all-docs ()
"Verify docs for all special forms and every public var in `clojure/core'."
- (let ((syms (cider-sync-eval-and-parse
- "(->> (merge @#'clojure.repl/special-doc-map
+ (let ((syms (read
+ (nrepl-sync-request:eval
+ "(->> (merge @#'clojure.repl/special-doc-map
(->> (ns-map 'clojure.core)
(filter (every-pred
(comp var? val)
(complement (comp :private meta val))))))
(keys)
- (remove '#{.}))"))) ; emacs lisp chokes on the dot symbol
+ (remove '#{.}))" ; emacs lisp chokes on the dot symbol
+ nil nil t))))
(let (untested diffs)
(dolist (sym syms)
(let ((name (cond ((symbolp sym) (symbol-name sym))
diff --git a/test/cider-tests.el b/test/cider-tests.el
index abae19f3..78559a39 100644
--- a/test/cider-tests.el
+++ b/test/cider-tests.el
@@ -68,23 +68,24 @@
(ert-deftest test-cider-var-info ()
(noflet ((nrepl-send-sync-request (list)
- `(:value
- (dict
- "arglists" "([] [x] [x & ys])"
- "ns" "clojure.core"
- "name" "str"
- "column" 1
- "added" "1.0"
- "static" "true"
- "doc" "stub"
- "line" 504
- "file" "jar:file:/clojure-1.5.1.jar!/clojure/core.clj"
- "tag" "class java.lang.String")
- :done t))
+ '(dict
+ "value" (dict
+ "arglists" "([] [x] [x & ys])"
+ "ns" "clojure.core"
+ "name" "str"
+ "column" 1
+ "added" "1.0"
+ "static" "true"
+ "doc" "stub"
+ "line" 504
+ "file" "jar:file:/clojure-1.5.1.jar!/clojure/core.clj"
+ "tag" "class java.lang.String")
+ "status" ("done")))
+ (cider-ensure-op-supported (op) t)
(nrepl-current-session () nil)
(cider-current-ns () "user"))
- (should (equal (nrepl-dict-get (cider-var-info "str") "doc") "stub" ))
- (should (not (cider-var-info "")))))
+ (should (equal "stub" (nrepl-dict-get (cider-var-info "str") "doc")))
+ (should (null (cider-var-info "")))))
(ert-deftest test-nrepl-dict-get ()
(let ((var-info '(dict "doc" "var doc" "arglists" "var arglists")))
diff --git a/test/nrepl-bencode-tests.el b/test/nrepl-bencode-tests.el
index e528bfcc..9755c735 100644
--- a/test/nrepl-bencode-tests.el
+++ b/test/nrepl-bencode-tests.el
@@ -307,7 +307,30 @@ If object is incomplete, return a decoded path."
(nrepl-dict-keys '(dict (2 . 3) (3 . 4) (4 . 5)))))
(should (equal '(1 5 9)
(nrepl-dict-map (lambda (k v) (+ k v))
- '(dict 0 1 2 3 4 5)))))
+ '(dict 0 1 2 3 4 5))))
+ (should (equal '(dict "id" "1"
+ "session" "blabla"
+ "a" (1 11)
+ "a2" (1 2 11)
+ "b" (1 2 11 22)
+ "c" "aaaaaAAAAA"
+ "d" (dict "a" "aaaaaAAAAA"
+ "b" "BBBBB"))
+ (nrepl--merge '(dict "id" "1"
+ "session" "blabla"
+ "a" 1
+ "a2" (1 2)
+ "b" (1 2)
+ "c" "aaaaa"
+ "d" (dict "a" "aaaaa"))
+ '(dict "id" "2"
+ "session" "bombom"
+ "a" 11
+ "a2" 11
+ "b" (11 22)
+ "c" "AAAAA"
+ "d" (dict "a" "AAAAA"
+ "b" "BBBBB"))))))
;; benchmarks