]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a test for primitive advicing effectiveness
authorAndrea Corallo <akrl@sdf.org>
Wed, 23 Sep 2020 07:36:49 +0000 (09:36 +0200)
committerAndrea Corallo <akrl@sdf.org>
Thu, 24 Sep 2020 07:57:17 +0000 (09:57 +0200)
* 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
test/src/comp-tests.el

index fe9943a1b91ea5ebf5a13e69381d3a36796c9f0a..19acec2716ec5fd65192ec88041e16ff3728a5e3 100644 (file)
         (concat head-padding (substring str from-idx idx)
                tail-padding ellipsis)))))
 
+(defun comp-test-primitive-advice-f (x y)
+  (declare (speed 2))
+  (+ x y))
+
 \f
 ;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests ;;
index 220bf1c77361eef5d8569490066fb121ab19b6ac..356bd876ffb6d91c11069b96cb9e4f1677833fef 100644 (file)
@@ -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))))
+
 \f
 ;;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests. ;;