From 0cc1804d42e25e0213f8b3872cc6133c6480a5b0 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Wed, 23 Sep 2020 09:36:49 +0200 Subject: [PATCH] Add a test for primitive advicing effectiveness * test/src/comp-test-funcs.el (comp-test-primitive-advice-f): New function. * test/src/comp-tests.el (comp-test-primitive-advice): New test. --- test/src/comp-test-funcs.el | 4 ++++ test/src/comp-tests.el | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/test/src/comp-test-funcs.el b/test/src/comp-test-funcs.el index fe9943a1b91..19acec2716e 100644 --- a/test/src/comp-test-funcs.el +++ b/test/src/comp-test-funcs.el @@ -337,6 +337,10 @@ (concat head-padding (substring str from-idx idx) tail-padding ellipsis))))) +(defun comp-test-primitive-advice-f (x y) + (declare (speed 2)) + (+ x y)) + ;;;;;;;;;;;;;;;;;;;; ;; Tromey's tests ;; diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index 220bf1c7736..356bd876ffb 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el @@ -375,6 +375,19 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html." (should (string= (comp-test-42360-f "Nel mezzo del " 18 0 32 "yyy" nil) "Nel mezzo del yyy"))) +(defvar comp-test-primitive-advice) +(ert-deftest comp-test-primitive-advice () + "Test effectiveness of primitve advicing." + (let (comp-test-primitive-advice + (f (lambda (&rest args) + (setq comp-test-primitive-advice args)))) + (advice-add #'+ :before f) + (unwind-protect + (progn + (should (= (comp-test-primitive-advice-f 3 4) 7)) + (should (equal comp-test-primitive-advice '(3 4)))) + (advice-remove #'+ f)))) + ;;;;;;;;;;;;;;;;;;;;; ;; Tromey's tests. ;; -- 2.39.5