emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/buttercup 8628d45 208/340: Merge pull request #147 from sn


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 8628d45 208/340: Merge pull request #147 from snogge/suite-local-function
Date: Thu, 16 Dec 2021 14:59:35 -0500 (EST)

branch: elpa/buttercup
commit 8628d45b1570a41f857e2e938caa946707f08dd3
Merge: d2b6692 e62ce43
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #147 from snogge/suite-local-function
    
    test: Do not leak functions from "The Spy " suite
---
 tests/test-buttercup.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 06dcce4..e99a964 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -613,16 +613,27 @@
 ;;; Spies
 
 (describe "The Spy "
-  (let (test-function)
+  (let (saved-test-function saved-test-command)
     ;; We use `before-all' here because some tests need to access the
     ;; same function as previous tests in order to work, so overriding
     ;; the function before each test would invalidate those tests.
     (before-all
+      (setq saved-test-function (and (fboundp 'test-function)
+                                     (symbol-function 'test-function))
+            saved-test-command (and (fboundp 'test-command)
+                                    (symbol-function 'test-command)))
       (fset 'test-function (lambda (a b)
                              (+ a b)))
       (fset 'test-command (lambda ()
                             (interactive)
                             t)))
+    (after-all
+      (if saved-test-function
+          (fset 'test-function saved-test-function)
+        (fmakunbound 'test-function))
+      (if saved-test-command
+          (fset 'test-command saved-test-command)
+        (fmakunbound 'test-command)))
 
     (describe "`spy-on' function"
       (it "replaces a symbol's function slot"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]