branch: elpa/pacmacs
commit 5cb14f20fd4b92c2eaead72cd8c53b4c5e135f4f
Author: rexim <[email protected]>
Commit: rexim <[email protected]>
UT for pacmacs--replace-game-objects (#153)
---
test/pacmacs-test.el | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/test/pacmacs-test.el b/test/pacmacs-test.el
index 3852eca864..2575314fe9 100644
--- a/test/pacmacs-test.el
+++ b/test/pacmacs-test.el
@@ -66,3 +66,27 @@
(should (equal (pacmacs--run-away-direction runner bogey
blocked-tile-predicate)
'left))))
+
+(ert-deftest pacmacs--replace-game-objects-test ()
+ (let* ((game-objects '((:row 10 :column 20)
+ (:row 30 :column 40)))
+ (replaced-objects nil)
+ (destroyed-objects nil)
+ (new-constructor (-lambda (row column)
+ (setq replaced-objects
+ (cons (list :row (1+ row)
+ :column (1+ column))
+ replaced-objects))))
+ (old-destructor (-lambda (game-object)
+ (setq destroyed-objects (cons game-object
+ destroyed-objects)))))
+ (pacmacs--replace-game-objects game-objects new-constructor old-destructor)
+ (should (equal '((:row 10 :column 20)
+ (:row 30 :column 40))
+ game-objects))
+ (should (equal '((:row 31 :column 41)
+ (:row 11 :column 21))
+ replaced-objects))
+ (should (equal '((:row 30 :column 40)
+ (:row 10 :column 20))
+ destroyed-objects))))