Skip to content

Commit

Permalink
feat: use car-safe for set macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Walheimat committed Nov 16, 2023
1 parent 97ec975 commit f38796f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bydi.el
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ If CLEAR is t, clear the history of calls of that function."
"Check that VAR was set to TO.
If CLEAR is t, clear the history of assignments to that variable."
`(let ((actual (gethash ',var bydi--history)))
`(let ((actual (car-safe (gethash ',var bydi--history))))
,@(delq
nil
`((should (bydi-verify--was-set-to ',var ,to (car actual)))
`((should (bydi-verify--was-set-to ',var ,to actual))
,(when clear `(bydi-clear-mocks-for ',var))))))

(defmacro bydi-was-set-to-nth (var to index)
Expand All @@ -189,8 +189,8 @@ If CLEAR is t, clear the history of assignments to that variable."

(defmacro bydi-was-set-to-last (var to)
"Check that VAR was set to TO during last setting."
`(let ((actual (last (reverse (gethash ',var bydi--history)))))
(should (bydi-verify--was-set-to ',var ,to (car actual)))))
`(let ((actual (car-safe (last (reverse (gethash ',var bydi--history))))))
(should (bydi-verify--was-set-to ',var ,to actual))))

(defmacro bydi-was-set-n-times (var expected)
"Verify that VAR was set EXPECTED times."
Expand Down

0 comments on commit f38796f

Please sign in to comment.