Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

convert to hashtables expecting a list type alist

  • Loading branch information...
commit 330b517edb9d5b0521bb66882893a5f7b5582094 1 parent 967c23a
Nic Ferrier authored

Showing 1 changed file with 24 additions and 15 deletions. Show diff stats Hide diff stats

  1. +24 15 fakir.el
39 fakir.el
@@ -4,7 +4,7 @@
4 4 ;; Author: Nic Ferrier <nferrier@ferrier.me.uk>
5 5 ;; Maintainer: Nic Ferrier <nferrier@ferrier.me.uk>
6 6 ;; Created: 17th March 2012
7   -;; Version: 0.0.6
  7 +;; Version: 0.0.7
8 8 ;; Keywords: lisp, tools
9 9
10 10 ;; This file is NOT part of GNU Emacs.
@@ -66,9 +66,11 @@ The ALIST looks like a let-list."
66 66 (list (list :fakir-mock-process t))
67 67 alist)
68 68 do
69   - (if (and f (listp f))
70   - (puthash (car f) (cadr f) bindings)
71   - (puthash f nil bindings)))
  69 + (cond
  70 + ((and f (listp f))
  71 + (puthash (car f) (cadr f) bindings))
  72 + (t
  73 + (puthash f nil bindings))))
72 74 bindings))
73 75
74 76 (ert-deftest fakir--make-hash-table ()
@@ -113,7 +115,13 @@ We return what the BODY returned."
113 115 (pvbuf (make-symbol "buf"))
114 116 (result (make-symbol "result")))
115 117 `(let
116   - ((,pvvar (fakir--make-hash-table (quote ,process-bindings)))
  118 + ((,pvvar
  119 + (fakir--make-hash-table
  120 + (list ,@(loop for p in process-bindings
  121 + collect
  122 + (if (and p (listp p))
  123 + (list 'list `(quote ,(car p)) (cadr p))
  124 + (list 'cons `,p nil))))))
117 125 ;; For assigning the result of the body
118 126 ,result
119 127 ;; Dummy buffer variable for the process - we fill this in
@@ -166,8 +174,7 @@ We return what the BODY returned."
166 174 (set-process-buffer
167 175 (proc buffer)
168 176 (get-or-create-pvbuf proc buffer)))
169   - (setq ,result (progn ,@body))
170   - )
  177 + (setq ,result (progn ,@body)))
171 178 ;; Now clean up
172 179 (when (bufferp ,pvbuf)
173 180 (with-current-buffer ,pvbuf
@@ -178,19 +185,21 @@ We return what the BODY returned."
178 185
179 186 (defun fakir-test-mock-process ()
180 187 "A very quick function to test mocking process macro."
181   - (fakir-mock-process
182   - ((a 20)
183   - (:somevar 15))
184   - (let ((z 10))
185   - (let ((a "my string!!!"))
186   - (setq a (process-get t :somevar))
187   - a))))
  188 + (let ((somevalue 30))
  189 + (fakir-mock-process
  190 + ((a 20)
  191 + (:somevar 15)
  192 + (:othervar somevalue))
  193 + (let ((z 10))
  194 + (let ((a "my string!!!"))
  195 + (setq a (process-get t :somevar))
  196 + (list a (process-get t :othervar)))))))
188 197
189 198 (ert-deftest fakir-mock-process ()
190 199 "Test mock process."
191 200 :tags '(unit)
192 201 (let ((x (fakir-test-mock-process)))
193   - (should (equal 15 x))))
  202 + (should (equal '(15 30) x))))
194 203
195 204
196 205 ;; Time utils

0 comments on commit 330b517

Please sign in to comment.
Something went wrong with that request. Please try again.