|
72 | 72 | (defvar cider-testing-ansi-colors-vector
|
73 | 73 | ["black" "red3" "green3" "yellow3" "blue2"
|
74 | 74 | "magenta3" "cyan3" "gray90"]
|
75 |
| - "Vector of translations for ansi color codes") |
| 75 | + "Vector of translations for ansi color codes.") |
76 | 76 |
|
77 | 77 | (defmacro with-testing-ansi-table (colors &rest body)
|
| 78 | + (declare (indent 1)) |
78 | 79 | `(let* ((ansi-color-names-vector ,colors)
|
79 |
| - (ansi-color-map (ansi-color-make-color-map))) |
| 80 | + (ansi-color-map (ansi-color-make-color-map))) |
80 | 81 | ,@body))
|
81 | 82 |
|
82 | 83 | (describe "multiple calls to cider-repl--emit-output-at-pos"
|
|
101 | 102 | :to-equal '(foreground-color . "red3"))))))
|
102 | 103 |
|
103 | 104 | (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'. |
105 | 106 | PROPERTY shoudl be a symbol of either 'text, 'ansi-context or
|
106 | 107 | 'properties."
|
107 | 108 | (with-temp-buffer
|
108 | 109 | (with-testing-ansi-table cider-testing-ansi-colors-vector
|
109 | 110 | (cider-repl-reset-markers)
|
110 | 111 | (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)))))) |
115 | 116 |
|
116 | 117 | (describe "cider-repl--emit-output-at-pos"
|
117 | 118 | (it "prints simple strings"
|
118 | 119 | (expect (simulate-cider-output "hi" 'text)
|
119 | 120 | :to-equal "hi\n"))
|
120 | 121 |
|
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 "[30ma[0mb[31mcd" '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 "[30ma[0mb[31mcd" 'ansi-context))) |
| 133 | + (expect context :to-equal '((31) nil)))))) |
0 commit comments