@@ -359,4 +359,123 @@ is a string\")
359359 (expect (inf-clojure--string-boundaries " foo(bar)baz" " =>" " (" " )" )
360360 :to-equal '(3 8 11 ))))
361361
362+ (describe " inf-clojure-symbol-at-point"
363+ (it " returns the symbol under point"
364+ (ict-with-assess-buffers
365+ ((a (insert " map" )))
366+ (with-current-buffer a
367+ (goto-char 2 )
368+ (expect (inf-clojure-symbol-at-point) :to-equal " map" ))))
369+ (it " returns empty string when no symbol at point"
370+ (ict-with-assess-buffers
371+ ((a (insert " " )))
372+ (with-current-buffer a
373+ (expect (inf-clojure-symbol-at-point) :to-equal " " ))))
374+ (it " returns a hyphenated symbol"
375+ (ict-with-assess-buffers
376+ ((a (insert " my-function" )))
377+ (with-current-buffer a
378+ (goto-char 5 )
379+ (expect (inf-clojure-symbol-at-point) :to-equal " my-function" )))))
380+
381+ (describe " inf-clojure-fn-called-at-pt"
382+ (it " returns the function name inside a call"
383+ (ict-with-assess-buffers
384+ ((a (insert " (map inc [1 2 3])" )))
385+ (with-current-buffer a
386+ (goto-char 10 )
387+ (expect (inf-clojure-fn-called-at-pt) :to-equal 'map ))))
388+ (it " returns nil when not in a list"
389+ (ict-with-assess-buffers
390+ ((a (insert " foo" )))
391+ (with-current-buffer a
392+ (expect (inf-clojure-fn-called-at-pt) :to-be nil ))))
393+ (it " returns nil when car is not a symbol"
394+ (ict-with-assess-buffers
395+ ((a (insert " (42 foo)" )))
396+ (with-current-buffer a
397+ (goto-char 5 )
398+ (expect (inf-clojure-fn-called-at-pt) :to-be nil )))))
399+
400+ (describe " inf-clojure-input-filter"
401+ (it " rejects blank input"
402+ (expect (inf-clojure-input-filter " " ) :to-be nil ))
403+ (it " rejects single-letter keywords"
404+ (expect (inf-clojure-input-filter " :a" ) :to-be nil ))
405+ (it " accepts normal expressions"
406+ (expect (inf-clojure-input-filter " (+ 1 2)" ) :to-be-truthy ))
407+ (it " accepts multi-letter keywords"
408+ (expect (inf-clojure-input-filter " :foo" ) :to-be-truthy )))
409+
410+ (describe " inf-clojure--modeline-info"
411+ (it " returns 'no process' when inf-clojure-buffer is nil"
412+ (let ((inf-clojure-buffer nil ))
413+ (expect (inf-clojure--modeline-info) :to-equal " no process" )))
414+ (it " returns 'no process' when inf-clojure-buffer is a dead buffer"
415+ (let ((inf-clojure-buffer (generate-new-buffer " *dead*" )))
416+ (kill-buffer inf-clojure-buffer)
417+ (expect (inf-clojure--modeline-info) :to-equal " no process" ))))
418+
419+ (describe " inf-clojure-connected-p"
420+ (it " returns nil when inf-clojure-buffer is nil"
421+ (let ((inf-clojure-buffer nil ))
422+ (expect (inf-clojure-connected-p) :to-be nil ))))
423+
424+ (describe " inf-clojure--defun-at-point"
425+ (it " returns the text of the defun at point"
426+ (ict-with-assess-buffers
427+ ((a (insert " (defn foo [] :bar)" )))
428+ (with-current-buffer a
429+ (goto-char 5 )
430+ (expect (inf-clojure--defun-at-point) :to-equal " (defn foo [] :bar)" ))))
431+ (it " returns bounds when requested"
432+ (ict-with-assess-buffers
433+ ((a (insert " (defn foo [] :bar)" )))
434+ (with-current-buffer a
435+ (goto-char 5 )
436+ (let ((bounds (inf-clojure--defun-at-point t )))
437+ (expect (car bounds) :to-equal 1 )
438+ (expect (cdr bounds) :to-equal 19 ))))))
439+
440+ (describe " inf-clojure-eldoc-beginning-of-sexp"
441+ (it " returns 0 at the function name"
442+ (ict-with-assess-buffers
443+ ((a (insert " (map)" )))
444+ (with-current-buffer a
445+ (goto-char 2 )
446+ (expect (inf-clojure-eldoc-beginning-of-sexp) :to-equal 0 ))))
447+ (it " counts arguments correctly"
448+ (ict-with-assess-buffers
449+ ((a (insert " (map inc coll)" )))
450+ (with-current-buffer a
451+ (goto-char 10 )
452+ (expect (inf-clojure-eldoc-beginning-of-sexp) :to-equal 3 )))))
453+
454+ (describe " inf-clojure-eldoc-info-in-current-sexp"
455+ (it " returns function name and argument index"
456+ (ict-with-assess-buffers
457+ ((a (insert " (map inc coll)" )))
458+ (with-current-buffer a
459+ (goto-char 10 )
460+ (expect (inf-clojure-eldoc-info-in-current-sexp)
461+ :to-equal '(" map" 2 )))))
462+ (it " returns nil inside a string"
463+ (ict-with-assess-buffers
464+ ((a (insert " (println \" hello\" )" )))
465+ (with-current-buffer a
466+ (goto-char 14 )
467+ (expect (inf-clojure-eldoc-info-in-current-sexp) :to-be nil ))))
468+ (it " returns nil inside a vector"
469+ (ict-with-assess-buffers
470+ ((a (insert " [foo bar]" )))
471+ (with-current-buffer a
472+ (goto-char 5 )
473+ (expect (inf-clojure-eldoc-info-in-current-sexp) :to-be nil )))))
474+
475+ (describe " inf-clojure-eldoc-format-thing"
476+ (it " propertizes with function-name face"
477+ (let ((result (inf-clojure-eldoc-format-thing " map" )))
478+ (expect (get-text-property 0 'face result)
479+ :to-equal 'font-lock-function-name-face ))))
480+
362481; ;; inf-clojure-tests.el ends here
0 commit comments