emacs-diffs
[Top][All Lists]
Advanced

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

feature/native-comp 0cc1804 07/11: Add a test for primitive advicing eff


From: Andrea Corallo
Subject: feature/native-comp 0cc1804 07/11: Add a test for primitive advicing effectiveness
Date: Thu, 24 Sep 2020 04:13:18 -0400 (EDT)

branch: feature/native-comp
commit 0cc1804d42e25e0213f8b3872cc6133c6480a5b0
Author: Andrea Corallo <akrl@sdf.org>
Commit: Andrea Corallo <akrl@sdf.org>

    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 fe9943a..19acec2 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 220bf1c..356bd87 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. ;;



reply via email to

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