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

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

[elpa] externals/assess 29e80b7540 65/95: Ensure capture function return


From: ELPA Syncer
Subject: [elpa] externals/assess 29e80b7540 65/95: Ensure capture function returns correct value
Date: Tue, 19 Jul 2022 15:57:34 -0400 (EDT)

branch: externals/assess
commit 29e80b7540edb1a570b43a3b39b3e0643a9d56b5
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>

    Ensure capture function returns correct value
    
    Previously, assess-call-capture was forcing the return of internal data
    structures from the captured function. It now does not affect the return
    value at all.
---
 assess-call.el           |  3 ++-
 test/assess-call-test.el | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/assess-call.el b/assess-call.el
index dc30978852..78d61740a7 100644
--- a/assess-call.el
+++ b/assess-call.el
@@ -63,7 +63,8 @@ values of FN are returned instead."
         (let ((rtn (apply fn args)))
           (setq capture-store
                 (cons (cons args rtn)
-                      capture-store)))))))
+                      capture-store))
+          rtn)))))
 
 (defun assess-call-capture (sym-fn fn)
   "Trace all calls to SYM-FN when FN is called with no args.
diff --git a/test/assess-call-test.el b/test/assess-call-test.el
index 46e9cf953e..66da692039 100644
--- a/test/assess-call-test.el
+++ b/test/assess-call-test.el
@@ -137,5 +137,23 @@
      (assess-deliberate-error
       (not assess-call-test-hook)))))
 
+
+(ert-deftest assess-call-return-value ()
+  "Test that return of the instrumented form is not affected.
+
+The form that we are capturing should return the same value that
+it would were it not instrumented, which was not true with
+earlier versions of this library."
+  (should
+   (= 4
+      (let ((rtn-from-form))
+        (assess-call-capture
+         #'assess-call-capture-multiply
+         (lambda ()
+           (setq rtn-from-form
+                 (assess-call-capture-multiply 2 2))))
+        rtn-from-form))))
+
+
 (provide 'assess-call-test)
 ;;; assess-call-test ends here



reply via email to

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