File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## master (unreleased)
4
4
5
+ * [ #135 ] ( https://github.com/clojure-emacs/inf-clojure/pull/135 ) : Improve command sanitation code.
6
+
5
7
## 2.1.0 (2018-01-02)
6
8
7
9
### New Features
Original file line number Diff line number Diff line change @@ -307,10 +307,10 @@ It requires a REPL PROC for inspecting the correct type."
307
307
308
308
(defun inf-clojure--single-linify (string )
309
309
" Convert a multi-line STRING in a single-line STRING.
310
- It also reduces/adds redundant whitespace for readability. Note
311
- that this function will transform the empty string in \" \" (it
312
- adds an empty space). "
313
- (replace-regexp-in-string " [ \\ | \n ]+ " " " string ))
310
+ It also reduces redundant whitespace for readability."
311
+ ( thread-last string
312
+ ( replace-regexp-in-string " [ \\ | \n ]+ " " " )
313
+ (replace-regexp-in-string " $ " " " ) ))
314
314
315
315
(defun inf-clojure--trim-newline-right (string )
316
316
" Trim newlines (only) in STRING."
Original file line number Diff line number Diff line change 111
111
(expect (ict-bounds-string (inf-clojure-completion-bounds-of-expr-at-point))
112
112
:to-equal " deref" )))))
113
113
114
+ (describe " inf-clojure--single-linify"
115
+ (it " replaces newlines with whitespace"
116
+ (expect (inf-clojure--single-linify " (do\n (println \" hello world\" )\n )" ) :to-equal " (do (println \" hello world\" ) )" ))
117
+
118
+ (it " does not leave whitespace at the end"
119
+ (expect (inf-clojure--single-linify " (do\n (println \" hello world\" )\n )\n\n " ) :to-equal " (do (println \" hello world\" ) )" ))
120
+
121
+ (it " returns empty string in case of only newline"
122
+ (expect (inf-clojure--single-linify " \n\n\n\n " ) :to-equal " " )))
123
+
124
+ (describe " inf-clojure--sanitize-command"
125
+ (it " sanitizes the command correctly"
126
+ (expect (inf-clojure--sanitize-command " (doc println)" ) :to-equal " (doc println)\n " ))
127
+
128
+ (it " trims newline at the right of a command"
129
+ (expect (inf-clojure--sanitize-command " (doc println)\n\n\n\n " ) :to-equal " (doc println)\n " ))
130
+
131
+ (it " returns empty string when the command is empty"
132
+ (expect (inf-clojure--sanitize-command " " ) :to-equal " " )))
133
+
114
134
; ;; inf-clojure-tests.el ends here
You can’t perform that action at this time.
0 commit comments