]> git.eshelyaron.com Git - emacs.git/commitdiff
Use cl-letf instead of unwind-protect in a test
authorMauro Aranda <maurooaranda@gmail.com>
Fri, 20 Nov 2020 22:28:03 +0000 (19:28 -0300)
committerMauro Aranda <maurooaranda@gmail.com>
Fri, 20 Nov 2020 22:28:03 +0000 (19:28 -0300)
* test/lisp/cus-edit-tests.el (cus-edit-tests-customize-saved/show-obsolete):
Good use case for cl-letf, so use it.
Suggested by Stefan Monnier <monnier@iro.umontreal.ca> in:
https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg00914.html

test/lisp/cus-edit-tests.el

index 114e461b7aca7c3f1a09154f291ea54b4e7a91bc..bb88b8dd9fab62f17d31f6d92f0350f83d196763 100644 (file)
@@ -23,6 +23,7 @@
 
 (require 'ert)
 (require 'ert-x)
+(eval-when-compile (require 'cl-lib))
 (require 'cus-edit)
 
 (defmacro with-cus-edit-test (buffer &rest body)
 
 (ert-deftest cus-edit-tests-customize-saved/show-obsolete ()
   (with-cus-edit-test "*Customize Saved*"
-    (unwind-protect
-        (progn
-          (put 'cus-edit-tests--obsolete-option-tag 'saved-value '(t))
-          (customize-saved)
-          (should (search-forward cus-edit-tests--obsolete-option-tag nil t)))
-      (put 'cus-edit-tests--obsolete-option-tag 'saved-value nil))))
+    (cl-letf (((get 'cus-edit-tests--obsolete-option-tag 'saved-value) '(t)))
+      (customize-saved)
+      (should (search-forward cus-edit-tests--obsolete-option-tag nil t)))))
 
 (provide 'cus-edit-tests)
 ;;; cus-edit-tests.el ends here