emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/cider 1367b25eb3 3/3: PR feedback


From: ELPA Syncer
Subject: [nongnu] elpa/cider 1367b25eb3 3/3: PR feedback
Date: Sat, 24 Jun 2023 03:59:53 -0400 (EDT)

branch: elpa/cider
commit 1367b25eb38b74bd9f87c763d5631d602b7161ae
Author: vemv <vemv@users.noreply.github.com>
Commit: Bozhidar Batsov <bozhidar@batsov.dev>

    PR feedback
---
 cider-eldoc.el            | 13 +++++-----
 test/cider-eldoc-tests.el | 60 +++++++++++++++++++++++++++--------------------
 2 files changed, 41 insertions(+), 32 deletions(-)

diff --git a/cider-eldoc.el b/cider-eldoc.el
index 110276d131..0a43203bff 100644
--- a/cider-eldoc.el
+++ b/cider-eldoc.el
@@ -323,12 +323,13 @@ if the maximum number of sexps to skip is exceeded."
 (defun cider-eldoc-thing-type (eldoc-info)
   "Return the type of the ELDOC-INFO being displayed by eldoc.
 It can be a function or var now."
-  (pcase (lax-plist-get eldoc-info "type")
-    ("function" 'fn)
-    ("special-form" 'special-form)
-    ("macro" 'macro)
-    ("method" 'method)
-    ("variable" 'var)))
+  (or (pcase (lax-plist-get eldoc-info "type")
+        ("function" 'fn)
+        ("special-form" 'special-form)
+        ("macro" 'macro)
+        ("method" 'method)
+        ("variable" 'var))
+      'fn))
 
 (defun cider-eldoc-info-at-point ()
   "Return eldoc info at point.
diff --git a/test/cider-eldoc-tests.el b/test/cider-eldoc-tests.el
index b5d461a940..1033ebcef8 100644
--- a/test/cider-eldoc-tests.el
+++ b/test/cider-eldoc-tests.el
@@ -69,12 +69,16 @@
         (expect (cider--eldoc-format-class-names class-names)
                 :to-equal "(String StringBuffer CharSequence & 1 more)")))))
 
+;; NOTE: more cases could be added. Correct behavior is TBD, see 
https://github.com/clojure-emacs/orchard/issues/99
 (describe "cider-eldoc-thing-type"
   (it "Identifies special forms correctly"
     (let ((eldoc-info '("type" "special-form")))
       (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'special-form)))
   (it "Identifies functions correctly"
     (let ((eldoc-info '("type" "function")))
+      (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'fn)))
+  (it "Defaults to 'fn"
+    (let ((eldoc-info '("type" "made-up-123")))
       (expect (cider-eldoc-thing-type eldoc-info) :to-equal 'fn))))
 
 (describe "cider-eldoc-format-special-form"
@@ -89,16 +93,13 @@
       (cider-eldoc-format-special-form 'if 0 eldoc-info)
       (expect 'cider-eldoc-format-arglist :to-have-been-called-with '(("test" 
"then" "else?")) 0)))
   (it "Should not remove duplicates from special-form arglists that do not 
have duplicates"
-    (let ((eldoc-info '("ns" nil
-                        "symbol" "."
-                        "arglists" ((".instanceMember" "instance" "args*") 
(".instanceMember" "Classname" "args*") ("Classname/staticMethod" "args*") 
("Classname/staticField"))
-                        "type" "special-form")))
+    (let* ((arglists '((".instanceMember" "instance" "args*") 
(".instanceMember" "Classname" "args*") ("Classname/staticMethod" "args*") 
("Classname/staticField")))
+           (eldoc-info `("ns" nil
+                         "symbol" "."
+                         "arglists" ,arglists
+                         "type" "special-form")))
       (cider-eldoc-format-special-form 'if 0 eldoc-info)
-      (expect 'cider-eldoc-format-arglist :to-have-been-called-with 
'((".instanceMember" "instance" "args*")
-                                                                      
(".instanceMember" "Classname" "args*")
-                                                                      
("Classname/staticMethod" "args*")
-                                                                      
("Classname/staticField"))
-              0))))
+      (expect 'cider-eldoc-format-arglist :to-have-been-called-with arglists 
0))))
 
 (describe "cider-eldoc-format-thing"
   :var (class-names)
@@ -274,25 +275,32 @@
     (spy-on 'cider-connected-p :and-return-value t)
     (spy-on 'cider-eldoc--edn-file-p :and-return-value nil))
   (it "Should call cider-eldoc-format-variable for vars"
-    (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" 
"foo" "pos" 0 "eldoc-info" ("ns" "clojure.core" "symbol" "foo" "type" 
"variable" "docstring" "test docstring")))
-    (spy-on 'cider-eldoc-format-variable)
-    (cider-eldoc)
-    (expect 'cider-eldoc-format-variable :to-have-been-called-with "foo" 
'("ns" "clojure.core" "symbol" "foo" "type" "variable" "docstring" "test 
docstring")))
+    (let* ((info '("ns" "clojure.core" "symbol" "foo" "type" "variable" 
"docstring" "test docstring")))
+      (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" 
"foo" "pos" 0 "eldoc-info" ,info))
+      (spy-on 'cider-eldoc-format-variable)
+      (cider-eldoc)
+      (expect 'cider-eldoc-format-variable :to-have-been-called-with "foo" 
info)))
+
   (it "Should call cider-eldoc-format-special-form for special forms"
-    (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" "if" 
"pos" 0 "eldoc-info" ("ns" "clojure.core" "symbol" "if" "type" "special-form" 
"arglists" ("special form arglist"))))
-    (spy-on 'cider-eldoc-format-special-form)
-    (cider-eldoc)
-    (expect 'cider-eldoc-format-special-form :to-have-been-called-with "if" 0 
'("ns" "clojure.core" "symbol" "if" "type" "special-form" "arglists" ("special 
form arglist"))))
+    (let* ((info '("ns" "clojure.core" "symbol" "if" "type" "special-form" 
"arglists" ("special form arglist"))))
+      (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" 
"if" "pos" 0 "eldoc-info" ,info))
+      (spy-on 'cider-eldoc-format-special-form)
+      (cider-eldoc)
+      (expect 'cider-eldoc-format-special-form :to-have-been-called-with "if" 
0 info)))
+
   (it "Should call cider-eldoc-format-function for functions"
-    (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" 
"a-fn" "pos" 0 "eldoc-info" ("ns" "foo.bar" "symbol" "a-fn" "type" "function" 
"arglists" ("function arglist"))))
-    (spy-on 'cider-eldoc-format-function)
-    (cider-eldoc)
-    (expect 'cider-eldoc-format-function :to-have-been-called-with "a-fn" 0 
'("ns" "foo.bar" "symbol" "a-fn" "type" "function" "arglists" ("function 
arglist"))))
+    (let* ((info '("ns" "foo.bar" "symbol" "a-fn" "type" "function" "arglists" 
("function arglist"))))
+      (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" 
"a-fn" "pos" 0 "eldoc-info" ,info))
+      (spy-on 'cider-eldoc-format-function)
+      (cider-eldoc)
+      (expect 'cider-eldoc-format-function :to-have-been-called-with "a-fn" 0 
info)))
+
   (it "Should call cider-eldoc-format-function for macros"
-    (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value '("thing" 
"a-macro" "pos" 0 "eldoc-info" ("ns" "clojure.core" "symbol" "a-macro" "type" 
"macro" "arglists" ("macro arglist"))))
-    (spy-on 'cider-eldoc-format-function)
-    (cider-eldoc)
-    (expect 'cider-eldoc-format-function :to-have-been-called-with "a-macro" 0 
'("ns" "clojure.core" "symbol" "a-macro" "type" "macro" "arglists" ("macro 
arglist")))))
+    (let* ((info '("ns" "clojure.core" "symbol" "a-macro" "type" "macro" 
"arglists" ("macro arglist"))))
+      (spy-on 'cider-eldoc-info-in-current-sexp :and-return-value `("thing" 
"a-macro" "pos" 0 "eldoc-info" ,info))
+      (spy-on 'cider-eldoc-format-function)
+      (cider-eldoc)
+      (expect 'cider-eldoc-format-function :to-have-been-called-with "a-macro" 
0 info))))
 
 (describe "cider-eldoc-format-sym-doc"
   :var (eldoc-echo-area-use-multiline-p)
@@ -364,6 +372,6 @@
   (it "adds the datomic query inputs of the query at point to the arglist"
     (spy-on 'cider-second-sexp-in-list :and-return-value t)
     (spy-on 'cider-sync-request:eldoc-datomic-query
-              :and-return-value '(dict "inputs" (("$" "?first-name"))))
+            :and-return-value '(dict "inputs" (("$" "?first-name"))))
     (expect (cider--eldoc-add-datomic-query-inputs-to-arglists '(("query" "&" 
"inputs")))
             :to-equal '(("query" "$" "?first-name")))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]