Skip to content

Commit 70dbc8f

Browse files
committed
Improve the code style a bit
1 parent 357d5b9 commit 70dbc8f

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

test/cider-repl-tests.el

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@
7272
(defvar cider-testing-ansi-colors-vector
7373
["black" "red3" "green3" "yellow3" "blue2"
7474
"magenta3" "cyan3" "gray90"]
75-
"Vector of translations for ansi color codes")
75+
"Vector of translations for ansi color codes.")
7676

7777
(defmacro with-testing-ansi-table (colors &rest body)
78+
(declare (indent 1))
7879
`(let* ((ansi-color-names-vector ,colors)
79-
(ansi-color-map (ansi-color-make-color-map)))
80+
(ansi-color-map (ansi-color-make-color-map)))
8081
,@body))
8182

8283
(describe "multiple calls to cider-repl--emit-output-at-pos"
@@ -101,29 +102,32 @@
101102
:to-equal '(foreground-color . "red3"))))))
102103

103104
(defun simulate-cider-output (s property)
104-
"Return properties from cider-repl--emit-output-at-pos.
105+
"Return properties from `cider-repl--emit-output-at-pos'.
105106
PROPERTY shoudl be a symbol of either 'text, 'ansi-context or
106107
'properties."
107108
(with-temp-buffer
108109
(with-testing-ansi-table cider-testing-ansi-colors-vector
109110
(cider-repl-reset-markers)
110111
(cider-repl--emit-output-at-pos (current-buffer) s nil (point-min) nil))
111-
(case property
112-
('text (substring-no-properties (buffer-string)))
113-
('ansi-context ansi-color-context)
114-
('properties (substring (buffer-string))))))
112+
(pcase property
113+
(`text (substring-no-properties (buffer-string)))
114+
(`ansi-context ansi-color-context)
115+
(`properties (substring (buffer-string))))))
115116

116117
(describe "cider-repl--emit-output-at-pos"
117118
(it "prints simple strings"
118119
(expect (simulate-cider-output "hi" 'text)
119120
:to-equal "hi\n"))
120121

121-
(it "when invlaid escape code, doesn't hold string looking for close tag"
122-
(expect (simulate-cider-output "\033hi" 'text)
123-
:to-equal "\033hi\n")
124-
(expect (simulate-cider-output "\033hi" 'ansi-context)
125-
:to-equal nil))
126-
127-
(it "preserves context when valid"
128-
(let ((context (simulate-cider-output "abcd" 'ansi-context)))
129-
(expect context :to-equal '((31) nil)))))
122+
;; https://github.com/clojure-emacs/cider/issues/1794
123+
(describe "when the escape code is invalid"
124+
(it "doesn't hold the string looking for a close tag"
125+
(expect (simulate-cider-output "\033hi" 'text)
126+
:to-equal "\033hi\n")
127+
(expect (simulate-cider-output "\033hi" 'ansi-context)
128+
:to-equal nil)))
129+
130+
(describe "when the escape code is valid"
131+
(it "preserves the context"
132+
(let ((context (simulate-cider-output "abcd" 'ansi-context)))
133+
(expect context :to-equal '((31) nil))))))

0 commit comments

Comments
 (0)