|
28 | 28 | ;;; Code:
|
29 | 29 |
|
30 | 30 | (require 'buttercup)
|
| 31 | +(require 'cl-lib) |
31 | 32 | (require 'nrepl-client)
|
32 | 33 |
|
33 | 34 | (defun nrepl-bdecode-string (string)
|
@@ -74,8 +75,10 @@ If object is incomplete, return a decoded path."
|
74 | 75 | (it "decodes queues"
|
75 | 76 | (expect (nrepl-bdecode "lli1ei2ei3eeli5ei6eee")
|
76 | 77 | :to-equal (cons
|
77 |
| - [cl-struct-queue nil nil] |
78 |
| - [cl-struct-nrepl-response-queue (((1 2 3) (5 6))) (((1 2 3) (5 6))) nil]))) |
| 78 | + (make-queue) |
| 79 | + (let ((q (nrepl-response-queue))) |
| 80 | + (queue-enqueue q '((1 2 3) (5 6))) |
| 81 | + q)))) |
79 | 82 |
|
80 | 83 | (it "decodes list of ints"
|
81 | 84 | (expect (nrepl-bdecode-string "li1ei2ei3ei4ei5ei6ei7ei8ee")
|
@@ -164,28 +167,25 @@ If object is incomplete, return a decoded path."
|
164 | 167 | items, returns val and f is not called.
|
165 | 168 | 7:session36:6fc999d0-3795-4d51-85fc-ccca7537ee57ed2:id2:182:ns4:user7:session36:6fc999d0-3795-4d51-85fc-ccca7537ee575:value3:niled2:id2:187:session36:6fc999d0-3795-4d51-85fc-ccca7537ee576:statusl4:doneee")
|
166 | 169 | :to-equal (cons
|
167 |
| - [cl-struct-queue nil nil] |
168 |
| - [cl-struct-nrepl-response-queue |
169 |
| - ((dict "id" "18" |
170 |
| - "out" "clojure.core/reduce\n" |
171 |
| - "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57") |
172 |
| - (dict "id" "18" |
173 |
| - "out" "([f coll] [f val coll])\n" |
174 |
| - "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57") |
175 |
| - (dict "id" "18" |
176 |
| - "out" " f should be a function of 2 arguments. If val is not supplied,\n returns the result of applying f to the first 2 items in coll, then\n applying f to that result and the 3rd item, etc. If coll contains no\n items, f must accept no arguments as well, and reduce returns the\n result of calling f with no arguments. If coll has only 1 item, it\n is returned and f is not called. If val is supplied, returns the\n result of applying f to val and the first item in coll, then\n applying f to that result and the 2nd item, etc. If coll contains no\n items, returns val and f is not called.\n" |
177 |
| - "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57") |
178 |
| - (dict "id" "18" |
179 |
| - "ns" "user" |
180 |
| - "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57" |
181 |
| - "value" "nil") |
182 |
| - (dict "id" "18" |
183 |
| - "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57" |
184 |
| - "status" ("done"))) |
185 |
| - ((dict "id" "18" |
186 |
| - "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57" |
187 |
| - "status" ("done"))) |
188 |
| - nil]))) |
| 170 | + (make-queue) |
| 171 | + (cl-reduce (lambda (q dict) (queue-enqueue q dict) q) |
| 172 | + '((dict "id" "18" |
| 173 | + "out" "clojure.core/reduce\n" |
| 174 | + "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57") |
| 175 | + (dict "id" "18" |
| 176 | + "out" "([f coll] [f val coll])\n" |
| 177 | + "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57") |
| 178 | + (dict "id" "18" |
| 179 | + "out" " f should be a function of 2 arguments. If val is not supplied,\n returns the result of applying f to the first 2 items in coll, then\n applying f to that result and the 3rd item, etc. If coll contains no\n items, f must accept no arguments as well, and reduce returns the\n result of calling f with no arguments. If coll has only 1 item, it\n is returned and f is not called. If val is supplied, returns the\n result of applying f to val and the first item in coll, then\n applying f to that result and the 2nd item, etc. If coll contains no\n items, returns val and f is not called.\n" |
| 180 | + "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57") |
| 181 | + (dict "id" "18" |
| 182 | + "ns" "user" |
| 183 | + "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57" |
| 184 | + "value" "nil") |
| 185 | + (dict "id" "18" |
| 186 | + "session" "6fc999d0-3795-4d51-85fc-ccca7537ee57" |
| 187 | + "status" ("done"))) |
| 188 | + :initial-value (nrepl-response-queue))))) |
189 | 189 |
|
190 | 190 | (it "decodes nrepl responses with multibyte chars"
|
191 | 191 | (expect (nrepl-bdecode-string
|
@@ -214,9 +214,12 @@ If object is incomplete, return a decoded path."
|
214 | 214 | (it "decodes queues"
|
215 | 215 | (expect (nrepl-bdecode "lli1ei2ei3eeli5ei6eeelli1ei2ei3eeli5ei6")
|
216 | 216 | :to-equal (cons
|
217 |
| - [cl-struct-queue ("i6") ("i6")] |
218 |
| - [cl-struct-nrepl-response-queue (((1 2 3) (5 6))) (((1 2 3) (5 6))) |
219 |
| - ((5) ((1 2 3)))])))) |
| 217 | + (let ((q (make-queue))) |
| 218 | + (queue-enqueue q "i6") |
| 219 | + q) |
| 220 | + (let ((q (nrepl-response-queue '((5) ((1 2 3)))))) |
| 221 | + (queue-enqueue q '((1 2 3) (5 6))) |
| 222 | + q))))) |
220 | 223 |
|
221 | 224 | (describe "when bencode strings are split into parts"
|
222 | 225 | (it "decodes dict"
|
|
0 commit comments